从未创建 tabBarController 的类访问它?
我正在开发一个 iPhone 应用程序,最终用户首先看到的是带有五个 UIButton 的“主”屏幕。点击这些按钮中的任何一个后,它们都会进入标签栏控制器视图,底部有五个选项卡,对应于(现在)上一个主屏幕上的每个 UIButton。
我目前正在我的应用程序委托中创建选项卡栏控制器,并在同一位置加载主视图控制器。
但我无法让主视图控制器中的 UIButtons 工作。我这样称呼不同的选项卡:
- (void) homeBtnSelect:(UIButton *)button {
if (button == button1) {
self.tabBarController.selectedIndex = 0;
}
if (button == button2) {
self.tabBarController.selectedIndex = 1;
}
//etc etc...
}
我假设我需要将 tabBarController 加载到主视图控制器中。但我不知道该怎么做。有人可以帮忙吗?
如果需要,我可以提供更多代码。提前致谢!
I'm developing an iPhone app, in which the first thing the end user sees is a "home" screen with five UIButtons. Upon tapping any one of those buttons, They're taken to a tab bar controller view with five tabs on the bottom, corresponding to the each of the UIButtons on the (now) previous home screen.
I'm currently creating my tab bar controller in my App Delegate, and loading the home view controller in the same place.
But I can't get the UIButtons in the Home View Controller to work. I call the different tabs like such:
- (void) homeBtnSelect:(UIButton *)button {
if (button == button1) {
self.tabBarController.selectedIndex = 0;
}
if (button == button2) {
self.tabBarController.selectedIndex = 1;
}
//etc etc...
}
I'm assuming I'll need to load the tabBarController into the home view controller. But I don't know how to do that. Can anyone help?
I can provide more code if needed. Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为了选择特定的
viewController
你必须设置selectedViewController
属性......你可以通过从tabBarController.viewControllers
数组获取 viewcontroller 来做到这一点......然后设置selectedViewController
属性......In order to select particular
viewController
you have to setselectedViewController
property..... you can do this by getting viewcontroller fromtabBarController.viewControllers
array..... and then settingselectedViewController
property.......