29,027
社区成员
发帖
与我相关
我的任务
分享
- (void)viewDidLoad {
[super viewDidLoad];
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
self.RadioButton1.selected = [defaults boolForKey:@"radiobutton"];
self.RadioButton2.selected = [defaults boolForKey:@"radiobutton"];
self.RadioButton3.selected = [defaults boolForKey:@"radiobutton"];
[self.RadioButton1 addTarget:self action:@selector(RadioButton1) forControlEvents:(UIControlEventValueChanged)];
[self.view addSubview:self.RadioButton1];
// Do any additional setup after loading the view.
}
- (IBAction)onRadioBtn:(RadioButton *)sender {
_statusLabel.text = [NSString stringWithFormat:@"%@",sender.titleLabel.text];
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
BOOL isSelected=[[NSUserDefaults standardUserDefaults]boolForKey:@"radiobutton"];
isSelected=!isSelected;
[defaults setBool:sender.selected forKey:@"radiobutton"];
[defaults synchronize];
}
@end