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或視圖控制器層次結構將不處於可以容納演示文稿的狀態。

相關問題