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

我想在选项卡内加载SFSafariViewController,因此选项卡栏位于整个Safari视图的底部.

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

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

Safari视图是否需要全屏显示

解决方法

我能够以编程方式实现这一目标.他们关键是在UIViewController顶部没有UITabBar叠加层,将半透明设置为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:@"https://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 16 更新版本时,我们听到了困扰 Apple...
欧版/美版 特别说一下,美版选错了 可能会永久丧失4G,不过只...
一般在接外包的时候, 通常第三方需要安装你的app进行测...
前言为了让更多的人永远记住12月13日,各大厂都在这一天将应...