gpt4 book ai didi

ios - 是否可以在 UITabBarController 中显示 SFSafariViewController?

转载 作者:技术小花猫 更新时间:2023-10-29 11:05:11 24 4
gpt4 key购买 nike

我想在选项卡中加载 SFSafariViewController,因此选项卡栏位于整个 Safari View 的底部。

这可能吗?我没有运气就试过了:

[self.tabBarController presentViewController:sfController animated:YES completion:nil];

要求 Safari View 是全屏的吗?

最佳答案

我能够以编程方式实现这一点。不在 UIViewController 上覆盖 UITabBar 的关键是将 translucent 设置为 NO:

在你的 AppDelegate.m 中:

@import SafariServices;

// ...

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.

self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];

UITabBarController *tabBarController = [[UITabBarController alloc] init];
tabBarController.tabBar.translucent = NO;

SFSafariViewController *firstVC = [[SFSafariViewController alloc] initWithURL:[NSURL URLWithString:@"http://stackoverflow.com"]];

firstVC.title = @"SFSafariViewController";

UIViewController *secondVC = [[UIViewController alloc] init];
secondVC.view.backgroundColor = [UIColor blueColor];

secondVC.title = @"Blue VC";

tabBarController.viewControllers = @[firstVC, secondVC];

self.window.rootViewController = tabBarController;
[self.window makeKeyAndVisible];

return YES;
}

关于ios - 是否可以在 UITabBarController 中显示 SFSafariViewController?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37084311/

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