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

前端之家收集整理的这篇文章主要介绍了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;
}
原文链接:https://www.f2er.com/iOS/333297.html

猜你在找的iOS相关文章