我是 iphone 的新手。我正在做一个项目,因为我在中间被击中了。我的问题是我的应用程序中有一个按钮,当我们单击时,我放置了一个代码来更改按钮的标题,如下所示
- (IBAction)syncOffClickedInRegisterUserScreen:(id)sender {
if ([syncOnorOff.titleLabel.text isEqualToString:@"Sync off"]) {
[syncOnorOff setTitle:@"Sync on" forState:UIControlStateNormal];
}
else{
[syncOnorOff setTitle:@"Sync off" forState:UIControlStateNormal];
}
}
它在这里正常工作是应用程序进入后台的代码
- (void)applicationDidEnterBackground:(UIApplication *)application {
NSLog(@"1");
registerUserScreen = [[RegisterUserScreen alloc]init];
//if([[[registerUserScreen syncOnorOff]currentTitle]isEqualToString:@"Sync off"]){
// NSLog(@"title is %@",[[registerUserScreen syncOnorOff]currentTitle]);
NSTimeInterval interval = 1;
NSDate *alertTime = [NSDate dateWithTimeIntervalSinceNow:interval];
UIApplication *app = [UIApplication sharedApplication];
UILocalNotification *notifyAlarm = [[UILocalNotification alloc]init];
if(notifyAlarm){
notifyAlarm.fireDate = alertTime;
notifyAlarm.alertBody = @"Sync Events";
notifyAlarm.alertAction = @"Sync";
notifyAlarm.timeZone = [NSTimeZone defaultTimeZone];
[app scheduleLocalNotification:notifyAlarm];
}
}
我的问题是每当用户屏幕中的标题同步关闭并进入后台状态时,它将执行后台的数据,如果用户屏幕中标题同步打开的按钮进入后台状态,它不会执行后台的数据。怎么可能。如果有人知道,请帮助我.....