2016-03-02 13 views
1

我曾经在我的应用程序,远程推送通知时打开的应用程序被关闭,并通知出现在iPhone和用户打开它,应用程序在指定的视图中打开,在正常的这种观点有后退按钮viewcontrolA,但是从通知打开时返回按钮不好玩,我需要帮助来解决它。 normal view when open from app view when opened from remote push notification后退按钮消失的时候认为从远程推送通知

didFinishLaunchingWithOptions:

 if (launchOptions != nil) 
     { 
      NSDictionary* dictionary1 = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey]; 
      NSDictionary* dictionary2 = [launchOptions objectForKey:UIApplicationLaunchOptionsLocalNotificationKey]; 
      if (dictionary1 != nil) 
      { 
       NSLog(@"Launched from push notification: %@", dictionary1); 
       double delayInSeconds = 7; 
       dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC)); 
       dispatch_after(popTime, dispatch_get_main_queue(), ^(void){ 
        // [self addMessageFromRemoteNotification:dictionary1 updateUI:NO]; 
       }); 

[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent]; 
      UIStoryboard *story=[UIStoryboard storyboardWithName:@"MainiPad" bundle:nil]; 
      MFSideMenuContainerViewController *controller=(MFSideMenuContainerViewController*)self.window.rootViewController; 
      UINavigationController *mainVC=[story instantiateViewControllerWithIdentifier:DetailsSearchNav]; 
      [self.window makeKeyAndVisible]; 
      [controller.shadow setOpacity:0.75f]; 
      [controller setCenterViewController:mainVC]; 
      UIViewController *leftController=[story instantiateViewControllerWithIdentifier:@"LeftSideViewController"]; 
      [controller setRightMenuViewController:leftController]; 
      [controller setLeftMenuViewController:nil]; 
      } 

      if (dictionary2 != nil) 
      { 
       NSLog(@"Launched from dictionary2dictionary2dictionary2 notification: %@", dictionary2); 
       double delayInSeconds = 7; 
       dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC)); 
       dispatch_after(popTime, dispatch_get_main_queue(), ^(void){ 
        // [self addMessageFromRemoteNotification:dictionary2 updateUI:NO]; 
       }); 
      } 

     } 
+0

,我认为你提出的viewcontrller –

+0

我推出它从应用委托 –

+0

你能证明你的代码 –

回答

0

是因为你设置房产详细信息ViewController作为UINavigationController根控制器。因此它不知道以前的ViewController导航。

+0

谢谢你这是与我一起工作的完美人选。 –

3

后退按钮时,才会有一种观点回去导航堆栈显示。

+0

好人,好方法 –

+0

谢谢你的帮助 –

+0

没问题。 – bisma

1

作为UINavigationController层次你,我们的屏幕上后退按钮显示在默认情况下,因为从列表页浏览。当你来到viewcontrolerNotification在那个时候Property Detauls查看成为Rootviewcontrollers。所以以下是逻辑。

  • 以编程方式在详细信息视图控制器中设置后退按钮。并在他们的事件,你只需要检查是viewcontroler是从推viewcontrolerrootviewcontroller打开,并根据条件编码。

  • 如果openviewcontroller作为rootviewcontrolelr然后回来点击你需要使用window对象添加新RootViewController的。

  • 否则,早工作parfect流行到视图控制器。

+0

完美的@Nitin Gohel –