0
林與計時器創建應用程序,並顯示彈出窗口埃夫裏30秒如何顯示UIAlertvew然後applicacation在後臺運行
- (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];
}
如何改變代碼顯示在後臺模式彈出窗口
Thnx它可以幫助我) – Ruslan
你能幫我添加NSTimer和UILocalNotification來添加appdelegate文件來每隔30秒顯示一次嗎? – Ruslan
當您在後臺時,NSTimer將無法工作,除非您開始後臺任務。請參閱http://developer.apple.com/library/ios/#DOCUMENTATION/iPhone/Conceptual/iPhoneOSProgrammingGuide/BackgroundExecution/BackgroundExecution.html –