登录界面的记住密码按钮,如何在下次app启动时显示上次关闭前的状态? 现在是这样写的: 全局变量:bool check = YES;
[[self.rememberbtn racsignalForControlEvents:UIControlEventTouchUpInside]subscribeNext:^(UIButton *btn) { UIImage *imgNormal = [UIImage imageNamed:@"ic_yes"]; UIImage *imgSelected = [UIImage imageNamed:@"ic_yes_press"]; NSUserDefaults *def =[NSUserDefaults standardUserDefaults]; if (check == YES) { [btn setImage:imgSelected forState:UIControlStateNormal]; [store setString:self.passWordText.text forKey:@"pwd"]; [store synchronize]; [def setObject:@"ic_yes_press" forKey:@"remember"]; [def synchronize]; check = NO; }else{ [btn setImage:imgNormal forState:UIControlStateNormal]; [store removeItemForKey:@"pwd"]; [store synchronize]; [def setObject:@"ic_yes" forKey:@"remember"]; [def synchronize]; check = YES; } -(void)viewWillAppear:(BOOL)animated{ [super viewWillAppear:YES]; NSUserDefaults *def = [NSUserDefaults standardUserDefaults]; if (nil != [def stringForKey:@"remember"]) { [self.remember_btn setImage:[UIImage imageNamed:[def stringForKey:@"remember"]] forState:UIControlStateNormal]; } } 怎么不行啊