【发布时间】:2019-01-03 21:58:02
【问题描述】:
收到推送通知时如何打开特定的标签栏?
我已经将[self.tabBarController setSelectedIndex:2];放在 viewDidAppear 上,并且在数据记录中发生了什么,它显示它通过 tabBar 2 viewController 但它没有打开/显示该页面并保留在 firstView 控制器/第一个 tabBar。
然后在我终止应用程序并重新打开后,它会自动/突然打开 tabBar 2 viewController。
谁能提供任何想法或示例代码来解决这个问题?
这是在我的 didReceiveRemoteNotification 中;
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
NSLog(@"Remote notification received");
if([userInfo valueForKey:@"app"]) {
NSString *action_app = [userInfo valueForKey:@"app"];
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:action_app forKey:@"app"];
NewVC *sample=[[NewVC alloc]init];
[sample viewDidLoad];
//[self.tabBarController setSelectedIndex:2];
[self clearNotifications];
}else{
NSLog(@"---nothing to read---");
}
}
NewVC 位于标签栏 2。
【问题讨论】:
-
在 appDelegate 的 didReceiveRemoteNotification 方法上写
setSelectedIndex代替 viewDidAppear。 -
@Viruss mca..我已经这样做了,但什么也没发生
-
显示你做了什么?
-
@Viruss mca..我已经在上面提出了问题的代码..
标签: ios objective-c cocoa-touch push-notification tabbar