簡體   English   中英

從AppDelegate.swift中的didReceiveLocalNotification推送ViewController

[英]Pushing ViewController from didReceiveLocalNotification in AppDelegate.swift

我在按下通知時從AppDelegate推送ViewController時遇到問題

下面是我的代碼,但是由於navigationController為nil,此代碼崩潰

func application(application: UIApplication, didReceiveLocalNotification notification: UILocalNotification) {

    var rootViewController = self.window!.rootViewController;

    let customDetailsViewController = CustomDetailsViewController();

    rootViewController?.navigationController!.pushViewController(customDetailsViewController, animated: true);
}

任何想法? 謝謝!!

如果導航控制器為nil,則rootViewController(情節提要中帶有箭頭的那個)不在NavigationController內。 您可以發布情節提要的相關部分的屏幕截圖嗎?

編輯

當您使用RESideController時 ,您將有一個RootViewController未連接到Storyboard中的任何東西。 RootViewController符合``protocol,您有一些類似的代碼:

@implementation FASRootViewController

- (void)awakeFromNib
{
    self.menuPreferredStatusBarStyle = UIStatusBarStyleLightContent;

    self.scaleContentView = NO;
    self.scaleMenuView = NO;
    self.panGestureEnabled = YES;

    self.contentViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"contentViewController"];
    self.rightMenuViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"rightMenuViewController"];
    self.delegate = (id<RESideMenuDelegate>)self.rightMenuViewController;
}

要“啟動” View控制器,需要在情節提要中添加標識符

在情節提要中添加一個標識符

此外,此視圖控制器應為UINavigationController(而不是您的第一個“內容”視圖控制器)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM