我有一个带有三个标签的标签栏控制器,我以编程方式设置。前两个只是UIViewController
,但第三个是我从另一个故事板得到的UISplitViewController
。一切都很好但是当我在肖像模式下显示主视图时,这个显示在标签栏的顶部。我想继续显示完整的标签栏。
当尝试在主视图中的项目栏按钮中显示UIAlertController
时,这也会产生问题(此按钮在图像中不存在),因为弹出显示在主视图后面。< / p>
有谁知道我该如何解决这个问题?
我以编程方式设置它的方式是这样的(如果它可能有帮助):
UIViewController *view1 = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"FirstView"];
UIViewController *view2 = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"SecondView"];
UIViewController *view3 = [[UIStoryboard storyboardWithName:@"StoryboardSplit" bundle:nil] instantiateViewControllerWithIdentifier:@"MySplitView"];
UISplitViewController *splitViewController = (UISplitViewController *)view3;
UINavigationController *navigationController = [splitViewController.viewControllers lastObject];
navigationController.topViewController.navigationItem.leftBarButtonItem = splitViewController.displayModeButtonItem;
splitViewController.delegate = self;
NSMutableArray *tabViewControllers = [[NSMutableArray alloc] init];
[tabViewControllers addObject:view1];
[tabViewControllers addObject:view2];
[tabViewControllers addObject:splitViewController];
[self setViewControllers:tabViewControllers];
view1.tabBarItem =
[[UITabBarItem alloc] initWithTitle:@"view1"
image:[UIImage imageNamed:@"view1"]
tag:1];
view2.tabBarItem =
[[UITabBarItem alloc] initWithTitle:@"view2"
image:[UIImage imageNamed:@"view2"]
tag:2];
view3.tabBarItem =
[[UITabBarItem alloc] initWithTitle:@"view3"
image:[UIImage imageNamed:@"view3"]
tag:3];
答案 0 :(得分:0)
尝试导入QuartzCore,然后设置TabBarController.tabBar.layer.zposition = 1.当然用tabBar的名称替换tabBar等必需品,依此类推。
这可以在Swift中使用,但是通过你自己的主动,你可以把它变成Obj-C