Iphone 收到本地通知时显示视图

Iphone 收到本地通知时显示视图,iphone,notifications,uilocalnotification,Iphone,Notifications,Uilocalnotification,对于iOS 5和故事板,当用户在收到本地通知后进入应用程序时,呈现视图的最佳方式是什么 我已经读到使用NSNotificationCenter是一种方法,但故事板和segues也是这样吗?这正是我实现它的方式。在AppDelegate的didFinishLaunchingWithOptions:方法中,我执行了以下操作: UILocalNotification *notification = [launchOptions objectForKey:UIApplicationLaun

对于iOS 5和故事板,当用户在收到本地通知后进入应用程序时,呈现视图的最佳方式是什么


我已经读到使用NSNotificationCenter是一种方法,但故事板和segues也是这样吗?

这正是我实现它的方式。在AppDelegate的didFinishLaunchingWithOptions:方法中,我执行了以下操作:

   UILocalNotification *notification = 
   [launchOptions objectForKey:UIApplicationLaunchOptionsLocalNotificationKey];
   [self application:application didReceiveLocalNotification:notification];
我这样做是为了把逻辑放在一个地方。在didreceiveLocalNotification:方法中,我使用了NSNotificationCenter:

    // Let another view handle the display        
    NSNotificationCenter * nc = [NSNotificationCenter defaultCenter];
    [nc postNotificationName:@"SHOW_VERSE" 
                      object:self 
                    userInfo:notification.userInfo];
处理显示的视图是故事板的第一个UIViewController。在该类中,在viewDidLoad方法中:

    [[NSNotificationCenter defaultCenter] addObserver:self  
                  selector:@selector(receivedLocalNotification:) 
                      name:@"SHOW_VERSE" 
                    object:nil];

这对我很有效。希望有帮助。

如何保证在发布通知之前调用viewDidLoad方法(并注册通知处理程序)?