我用计时器创建应用程序并每隔30秒显示弹出窗口
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[window addSubview:viewController.view];
[window makeKeyAndVisible];
timer = [NSTimer scheduledTimerWithTimeInterval:(30)
target:self
selector:@selector(showpopup:)
userInfo:nil
repeats:YES];
}
-(void) showpopup:(NSTimer *)theTimer{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"YAHooo!" message:nil delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
[alert release];
}
如何更改代码以在后台模式中显示弹出窗口
答案 0 :(得分:2)
当您的应用程序处于后台时,您无法显示UIAlertView。您可以使用UIAlertView格式的UILocalNotification,但每个应用程序的通知数量都有限制。要安排UILocalNotification,请按照tutorial。