gpt4 book ai didi

ios - 如何从 appdelegate 打开 View ?

转载 作者:行者123 更新时间:2023-11-29 11:51:32 24 4
gpt4 key购买 nike

我正在使用自定义 URL 方案打开我的应用程序。我下面的代码用于从标签栏打开一个 View 。但是我应该如何打开一个特定的 View 。

- (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;
}

最佳答案

您需要检查 url scheme 如下:

 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];
}

关于ios - 如何从 appdelegate 打开 View ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40927704/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com