我正在使用UILocalNotification.Here當我啓動通知時,我需要在應用程序中使用特定的視圖。但我已經嘗試過像下面的編碼。當用戶在ViewBased應用程序中啓動UILocalNotification時,打開一個特定的視圖控制器
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
[[UIApplication sharedApplication]setStatusBarHidden:NO];
SplashView *mySplash = [[SplashView alloc] initWithImage:
[UIImage imageNamed:@"Splash.png"]];
[window insertSubview:mySplash atIndex:1];
[window makeKeyAndVisible];
mySplash.delay = 5;
mySplash.animation = SplashViewAnimationFade;
[mySplash startSplash];
[self.window insertSubview:viewController.view atIndex:0];
[self.window makeKeyAndVisible];
[mySplash release];
// Add the view controller's view to the window and display. [self.window addSubview:viewController.view];
UILocalNotification *localNotification = [launchOptions objectForKey:UIApplicationLaunchOptionsLocalNotificationKey];
if (localNotification)
{
NSLog(@"Notification Body: %@",localNotification.alertBody);
NSLog(@"%@", localNotification.userInfo);
}
[[UIApplication sharedApplication] cancelAllLocalNotifications];
application.applicationIconBadgeNumber = 0;
return YES;
}
- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification {
UIApplicationState state = [application applicationState];
if (state == UIApplicationStateInactive) {
showItemContrller = [[Showitem alloc] initWithNibName:@"Showitem" bundle:nil];
[self.window addSubview:showItemContrller.view];
[self.window bringSubviewToFront:showItemContrller.view];
}
}
但是,當我啓動通知時,它顯示了它將要showItemControllerView幾秒鐘的前一個視圖。
感謝你
顯示它顯示的應用。所以以前的狀態如何避免這個ShowItemController之前? –