我使用自定义网址方案打开我的应用。 我的代码用于从标签栏打开视图。但是我应该如何打开一个特定的视图。
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
if ([url.host isEqual: @"main"])
{
UITabBarController *tab = (UITabBarController *)self.window.rootViewController;
tab.selectedIndex = 0;
}
答案 0 :(得分:1)
您需要检查网址方案如下:
if ([[url scheme] isEqualToString:@"main"]) {
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
UITabBarController *rootViewController = [storyboard instantiateViewControllerWithIdentifier:@"tabBarcontroller"]; // if you are use storyboard .
[self.Window setRootViewController:rootViewController];
}
答案 1 :(得分:0)
if ([[url scheme] isEqualToString:@"main"]) {
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
UITabBarController *rootViewController = [storyboard instantiateViewControllerWithIdentifier:@"tabBarcontroller"]; // if you are use storyboard .
tab.selectedIndex = 0;
[self.Window setRootViewController:rootViewController];
}