我想在选项卡内加载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;
- }