从 UIViewController 推送 UITabViewController 是可能的吗?
我的应用程序第一个 viewController 是 UIViewController。 当用户单击按钮firstView消失并推送UITabViewController 是否可以?
我找不到如何从 UIViewController 推送 UITabViewController。
my app first viewController is UIViewController.
and when user click button firstView disappear and push UITabViewController
is it possible?
i can't find how to push UITabViewController from UIViewController.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
更新抱歉,我误读了 UITableViewController 的 TabVC。您是指 UITableViewController 还是 UITabBarController?无论如何,我会在下面留下我的答案。
在这种情况下,通常最好将 UITabBarController 作为根视图对象。虽然可以做到,但在我看来,这是一个更混乱的实现。
事实上,我会将 UITabBarController 设为根,并在启动时从该 UITabBarController 模态显示 UIViewController。
用户将看到 UIViewController,当他们单击按钮时,关闭该模式视图,显示 UITabBarController。
只需使用 UINavigationController 即可。
使用导航控制器将 tableView 推入层次结构中的第二层。作为奖励,您将“免费”获得后退按钮,并且您不必担心代表返回到原始 UIViewController。
UPDATE sorry, I misread TabVC for UITableViewController. Do you mean UITableViewController or UITabBarController? I'll leave my answer below anyways.
In this instance, it's usually best to have a UITabBarController be the root view object. Although it can be done, it's a messier implementation, in my opinion.
I would in fact make the UITabBarController the root and display the UIViewController modally from that UITabBarController on launch.
The user would be presented with the UIViewController and when they clicked the button, dismiss that modal view, revealing the UITabBarController.
Just use a UINavigationController.
Use the navigation controller to push the tableView as the second level in the hierarchy. As a bonus you'll get the back button for 'free' and you don't have to worry about delegates for getting back to the original UIViewController.
你可以尝试这个:
self.tabBarController.selectedViewController
= [self.tabBarController.viewControllers objectAtIndex:2];
它应该可以工作,因为 selectedViewController 属性包含所选选项卡的视图。
you may try this:
self.tabBarController.selectedViewController
= [self.tabBarController.viewControllers objectAtIndex:2];
it should work because selectedViewController property contains view of selected tab.
首先你有视图控制器。并制作包含 tabbarcontroller 的 Second 视图控制器。现在只需按下第二个视图控制器。并将 tabbarcontroller 的视图作为子视图添加到第二个视图控制器。
希望你能明白..
First of all you have view controller . And make Second view controller which contain tabbarcontroller . Now just push second view controller . And add tabbarcontroller's view as a subview to second view controller .
Hope you gets it ..