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

前端之家收集整理的这篇文章主要介绍了ios – 是否可以在UITabBarController中显示SFSafariViewController?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我想在选项卡内加载SFSafariViewController,因此选项卡栏位于整个Safari视图的底部.

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

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

Safari视图是否需要全屏显示

解决方法

我能够以编程方式实现这一目标.他们关键是在UIViewController顶部没有UITabBar叠加层,将半透明设置为NO:

在你的AppDelegate.m中:

  1. @import SafariServices;
  2.  
  3. // ...
  4.  
  5. - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
  6. // Override point for customization after application launch.
  7.  
  8. self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
  9.  
  10. UITabBarController *tabBarController = [[UITabBarController alloc] init];
  11. tabBarController.tabBar.translucent = NO;
  12.  
  13. SFSafariViewController *firstVC = [[SFSafariViewController alloc] initWithURL:[NSURL URLWithString:@"https://stackoverflow.com"]];
  14.  
  15. firstVC.title = @"SFSafariViewController";
  16.  
  17. UIViewController *secondVC = [[UIViewController alloc] init];
  18. secondVC.view.backgroundColor = [UIColor blueColor];
  19.  
  20. secondVC.title = @"Blue VC";
  21.  
  22. tabBarController.viewControllers = @[firstVC,secondVC];
  23.  
  24. self.window.rootViewController = tabBarController;
  25. [self.window makeKeyAndVisible];
  26.  
  27. return YES;
  28. }

猜你在找的iOS相关文章