收到推送通知后显示模式
每当收到推送通知时(应用程序运行时),我需要显示通知模式。我的应用程序有一个选项卡栏,我通过将通知模式推到选项卡栏控制器上使其部分工作。
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
NotificationViewController *vc = [[NotificationViewController alloc] init];
[tabBarController presentModalViewController:vc animated:YES];
[vc release];
}
然而,当已经打开了隐藏选项卡栏控制器的不同模式时,这似乎失败了。确保在收到推送通知时,NotificationViewController 始终显示的最佳方法是什么,即使已经打开了隐藏选项卡栏控制器的模式?
I need to show a notification modal whenever a push notification is received (while the app is running). My app has a tab bar, and I've gotten this to partially work by pushing the notification modal onto the tab bar controller.
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
NotificationViewController *vc = [[NotificationViewController alloc] init];
[tabBarController presentModalViewController:vc animated:YES];
[vc release];
}
This seems to fail, however, when there is already a different modal open that hides the tab bar controller. What is the best way to make sure that the NotificationViewController always displays when a push notification is received, even if there is already a modal open that is hiding the tab bar controller?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以做两件事。首先是关闭当前的模态控制器,但这可能会让用户感到困惑。第二件事是这样的:
可能不是最漂亮的事情,因为它在模态控制器中打开另一个模态控制器,但它有效。
There are two things you can do. First is to dismiss current modal controller, but it could confuse the user. The second thing would be something like that:
Probably not the prettiest thing to do, as it opens another modal controller in a modal controller, but it works.