登录界面的记住密码按钮,如何在下次app启动时显示上次关闭前的状态?

pastjie 发布于 2014年09月09日
无人欣赏。 4人反对。

登录界面的记住密码按钮,如何在下次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]; } } 怎么不行啊

共1条回复
generalzyq 回复于 2014年09月11日

额。。。好混乱的格式啊。。。。所以大家才都没法帮你看的吧

登录 或者 注册