mos*_*fya 2 iphone xcode objective-c
我仔细阅读了苹果开发用户指南重新多任务,但我仍然无法理解如何在背景上运行简单的操作.我做了以下简单的实验但没有发生任何事情:
- (void)applicationDidEnterBackground:(UIApplication *)application
{
sleep(3);
UIAlertView *alert1 = [[UIAlertView alloc] initWithTitle:@"title" message:@"test" delegate:nil cancelButtonTitle:nil otherButtonTitles:nil , nil];
[alert1 show];
}
Run Code Online (Sandbox Code Playgroud)
所以我理解在默认情况下在后台添加对音频/位置/ VoIP操作的支持,但是如何添加对这种简单操作的支持?
非常感谢您的帮助.
我希望这个答案.对你的问题非常有用
关闭应用程序时,您可以在后台看到AlertView中的消息.
- (void)viewDidLoad
{
UILocalNotification *localNotif = [[UILocalNotification alloc] init];
localNotif.fireDate =[NSDate dateWithTimeIntervalSinceNow:15];
localNotif.timeZone = [NSTimeZone localTimeZone];
localNotif.alertBody = @"Staff meeting in 30 minutes";
//localNotif.alertBody = [NSString stringWithFormat:@"%@'s Birthday",strName];
localNotif.alertAction = @"View";
localNotif.soundName = UILocalNotificationDefaultSoundName;
// localNotif.applicationIconBadgeNumber = 1;
localNotif.repeatInterval = NSYearCalendarUnit;
[[UIApplication sharedApplication] scheduleLocalNotification:localNotif];
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
219 次 |
| 最近记录: |