我在项目中使用SWRevealViewController 2.3.0。我的故事板设计如下:https://i.stack.imgur.com/txv0G.png
当应用程序未运行(完全终止)并且出现推送通知时,如何让详细信息视图控制器显示并返回按钮主视图控制器?某些通知值应该已传递到"详细信息"视图。
谢谢你的帮助。
在这种情况下,我所做的是
你可以检查launchOptions
是否不是零didFinishLaunchingWithOptions
作为
if (launchOptions)
{
NSDictionary *dic = [launchOptions objectForKey:@"UIApplicationLaunchOptionsRemoteNotificationKey"];
[[NSUserDefaults standardUserDefaults] setObject:[dic objectForKey:@"aps"] forKey:@"PushNotification"];
}
else
{
[[NSUserDefaults standardUserDefaults] setObject:nil forKey:@"PushNotification"];
}
并像我一样保存在用户默认值中。
现在简单地说,当你在mainViewController
中时,你可以将其检查为
NSDictionary *notification = [[NSUserDefaults standardUserDefaults] objectForKey:@"PushNotification"];
if (notification)
{
// check the dictionary "Push Notification" Key Values that you are receiving to go in `DetailViewController`
// Now go to `DetailViewContoller` having your details from `PushNotification`by `performSegueWithIdentifier`
[self performSegueWithIdentifier:@"DetailViewController" sender:self];
// make this value nil for normal use
[[NSUserDefaults standardUserDefaults] setObject:nil forKey:@"PushNotification"];
}
如果您在这里没有将这个userDefaults值设置为nil,您也可以在DetailViewController中使用它,但不要忘记在使用后将其设置为nil。
使用这种方式,BACK按钮应显示在DetailViewController