我希望在点击远程通知后打开一个以tabbarviewcontroller为根的viewcontroller。这可能吗?
我正在打电话,所以我不能单独突出显示代码,但这里是
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
If(launchOptions[UIApplicationLaunchOptionsRemoteNotificationKey]){
//what do I put here?
}
答案 0 :(得分:0)
试试这个(我假设你的方法在你的AppDelegate
类中)
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
If(launchOptions[UIApplicationLaunchOptionsRemoteNotificationKey])
{
UITabBarController * tabController = (UITabBarController*)_window.rootViewController;
YourViewController * yvc = (YourViewController*)[tabController.viewControllers objectAtIndex:index];
[self.window.rootViewController presentViewController:yvc animated:YES completion:nil];
}
}
(或) 编辑:这可能有用
AppDelegate* appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
MainViewController *mvc = (MainViewController *)appDelegate.window.rootViewController;
YourViewController *yvc = (YourViewController*)[mvc.storyboard instantiateViewControllerWithIdentifier:@"ViewStoryBoardID"];
[self.window.rootViewController presentModalViewController:yvc animated:YES];