0

我试图打开子视图(PostReaderViewController,图像上的第四个视图)当应用程序通过推送通知午餐时它是。故事板图片: enter image description here 这是我的代码:Performe,导航,从应用程序委托子视图

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 
     ... 
    //Detecting if the app was lunched by clicking on push notification : 
    NSDictionary *userInfo = [launchOptions valueForKey:@"UIApplicationLaunchOptionsRemoteNotificationKey"]; 
    NSDictionary *apsInfo = [userInfo objectForKey:@"aps"]; 

    if(apsInfo) { 
     UIStoryboard *mainstoryboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil]; 
     PostReaderViewController* postReader = (PostReaderViewController *)[mainstoryboard instantiateViewControllerWithIdentifier:@"postReaderView"]; 
     CostumSDPost *tempPost = [[CostumSDPost alloc] init]; 
     tempPost.ID = userInfo[@"post_id"]; 
     postReader.thePost = tempPost; 
     [self.window.rootViewController presentViewController:postReader animated:YES completion:NULL]; 
     //userInfo[@"post_id"]); 
    } 
    return YES; 
} 

当我通过推送通知启动我的APP没有错误显示,但它unfortunly启动并显示默认的视图(图像第三视图)。
请注意,我使用SWRevealMenu和INTIAL点(图像查看首)是显示视图控制器

回答

0

上悬而未决此问题:

首先我创建全球布尔变量然后在AppDelegate中我设置VAR为YES,如果应用程序是通过推午饭通知符这样的:

//Detecting if the app was lunched by clicking on push notification : 
    NSDictionary *userInfo = [launchOptions valueForKey:@"UIApplicationLaunchOptionsRemoteNotificationKey"]; 
    NSDictionary *apsInfo = [userInfo objectForKey:@"aps"]; 
    if(apsInfo) { 
     // Set my global Var to YES 
     GlobalSingleton *global = [GlobalSingleton sharedInstance]; 
     global.displayFirstPost = YES; } 

然后在我的主屏幕我检查是否这个变量== YES然后导航到下一个屏幕自动其他显示主屏幕:

GlobalSingleton *global = [GlobalSingleton sharedInstance]; 
      if (global.displayFirstPost) { 
       // NAvigation code to the third Screen 
       } 
0

self.window.rootViewController需要在任何viewDidLoadviewDidAppear进行演示。如果你早一点做,那么rootViewController将是nil或视图控制器层次结构将不处于可以容纳演示文稿的状态。

相关问题