【发布时间】:2014-02-17 19:12:59
【问题描述】:
我正在开发一个应用程序,该应用程序的情节提要具有 3 个视图控制器和启用推送通知的应用程序。当我收到推送通知并且当我点击通知警报时,它应该从我的故事板中打开第二个视图控制器,让我显示我的代码。
-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
{
[[NSNotificationCenter defaultCenter] postNotificationName:@"pushNotification" object:nil userInfo:userInfo];
}
然后加载故事板,这实际上是我的第一个视图控制器,其中还有一个按钮到第二个视图控制器,这就是我要加载的控制器。这是我的第一个视图控制器中的代码。
- (void)viewDidLoad
{
[super viewDidLoad];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(pushNotificationReceived) name:@"pushNotification" object:nil];
}
-(void)pushNotificationReceived{
NSString * storyboardName = @"DealerMainStoryboard";
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:storyboardName bundle: nil];
UIViewController * vc = [storyboard instantiateViewControllerWithIdentifier:@"DealerBuyRequests"];
[self presentViewController:vc animated:YES completion:nil];
}
所以当我收到带有此代码的通知时,当我点击通知时应用程序崩溃。
【问题讨论】:
-
你的问题在哪里?
-
应用程序在收到 pushnotification 并且我点击通知时崩溃并显示此代码。
-
你的错误日志是什么?
-
我在临时生产 ipa 文件中检查它,那么我怎样才能得到错误日志呢?
-
也许在控制台上?
标签: ios objective-c storyboard push-notification