2012-06-26 32 views
0

我正在使用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幾秒鐘的前一個視圖。

感謝你

+0

顯示它顯示的應用。所以以前的狀態如何避免這個ShowItemController之前? –

回答

1
//comment this line.... 

//[self.window insertSubview:viewController.view atIndex:0]; 
+0

@Abishek然後在飛濺後它不會顯示任何視圖 –

+0

只是增加飛濺持續時間,直到你的通知沒有收到... – Abhishek

+0

Abishek你收到LocalNotification後會混淆它將去(void)應用程序:(UIApplication *)application didReceiveLocalNotification :(UILocalNotification *)通知,但不會進入DidFinishWithLaunch方法。 –

相關問題