如何向UIAlertview展示在后台运行的应用程序

时间:2011-07-15 07:14:38

标签: iphone xcode4 uialertview

我用计时器创建应用程序并每隔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];

}

如何更改代码以在后台模式中显示弹出窗口

1 个答案:

答案 0 :(得分:2)

当您的应用程序处于后台时,您无法显示UIAlertView。您可以使用UIAlertView格式的UILocalNotification,但每个应用程序的通知数量都有限制。要安排UILocalNotification,请按照tutorial