我会接受swift和objective-c的答案,因为翻译很容易。
我想显示带有启动画面的标签栏,但我不希望该启动画面位于标签栏项目中供选择。
我的设置现在(下方)显示着陆屏幕,显示标签栏时显示的第一个控制器。但是,我想隐藏标签栏项目。用户只能选择其他三个选项卡。我该怎么做?
//Create and add landing view
navigation = UINavigationController()
landingView = WGMLandingViewController(nibName: XIBFiles.LANDINGVIEW, bundle: nil)
navigation.pushViewController(landingView, animated: false)
navigation.title = "Landing View"
controllers.append(navigation)
//Create and add library view
navigation = UINavigationController()
libraryView = WGMLibraryViewController(nibName: XIBFiles.LIBRARYVIEW, bundle: nil)
navigation.pushViewController(libraryView, animated: false)
navigation.title = "Learn More"
controllers.append(navigation)
//Create and add pad view
navigation = UINavigationController()
orderPadView = WGMOrderPadViewController(nibName: XIBFiles.ORDERPADVIEW, bundle: nil)
navigation.pushViewController(orderPadView, animated: false)
navigation.title = "Order Pad"
controllers.append(navigation)
//Create and add lookup view
navigation = UINavigationController()
partLookupView = WGMLookupViewController(nibName: XIBFiles.LOOKUPVIEW, bundle: nil)
navigation.pushViewController(lookupView, animated: false)
navigation.title = "Lookup"
controllers.append(navigation)
//Set up controller list
self.setViewControllers(controllers, animated: false)
答案 0 :(得分:0)
Apple现有的API不允许你这样做,但是我们不应该太难去分类 UITabBarController
并让它做你想做的事。
好的..这些天我的原始答案不会起作用..或者我已经老了,它从来没有用过,我做了别的事情。 *咳嗽*
所以无论如何,你必须滚动自己的标签栏控制器。现在我们有了包容视图控制器并且您仍然可以使用UITabBar
,这并不是那么困难(只是耗时)。
UIViewController
(您的标签栏控制器),并在其中添加UITabBar
和UIView
。UITabBar
。delegate
的{{1}}设置为您的视图控制器并实施UITabBar
方法。didSelectItem
或您想要的位置。像
这样的东西viewDidLoad
然后,每当选择各种选项卡时,还要添加代码以加载相应的视图控制器
- (void)loadSplashScreen {
// load in the child view controller
UIViewController *splashScreenController = ...;
[self loadChildViewController:splashScreenController];
// make sure nothing in the tab bar is selected
self.tabBar.selectedItem = nil;
}