IBOutlet UISwitch --> value changed event
(UISlider也是類似此方式)
(UISlider也是類似此方式)
//
// PowerBankViewController.h
@interface PPowerBankViewController : UIViewController {
IBOutlet UISwitch *aSwitch;
}
@property (nonatomic, retain) IBOutlet UISwitch *aSwitch;
-(IBAction)onSwitch:(id)sender;
//
// PowerBankViewController.m
@synthesize aSwitch;
-(IBAction)onSwitch:(id)sender
{
aSwitch = (UISwitch *)sender;
NSLog(@"in onSwitch");
if ([aSwitch isOn] == YES) {
NSLog(@"[aSwitch isOn] == YES");
}
else{
NSLog(@"[aSwitch isOn] == NO");
}
}
- (void)viewDidLoad {
aSwitch = [[UISwitch alloc] init];
}
- (void)dealloc {
[aSwitch release];
[super dealloc];
}
沒有留言:
張貼留言