简体   繁体   English

如何将UItabBarController添加为子视图

[英]how to add UItabBarController as a subview

I have made a TabBar project using xcode's templates and I have the tabbar in the mainwindow.xib ofcourse. 我已经使用xcode的模板制作了一个TabBar项目,并且在mainwindow.xib中有一个tabbar。

once after the user logs into the app, I redirect them to a page called notifications, [self presentModalViewController:controller animated:YES]; 用户登录到应用程序后,我将其重定向到一个称为通知的页面, [self presentModalViewController:controller animated:YES]; but the tabbar doesnt show up. 但标签栏不显示。

now how can I either include the tabbar in the code above or get the tabbar from mainWindow.xib and display it once the UIView is loaded? 现在如何在上面的代码中包含标签栏,或者如何从mainWindow.xib获取标签栏,并在加载UIView后显示它?

Thanks 谢谢

Does your 'log in' view display the TabBar? 您的“登录”视图是否显示TabBar? If so, that's because your 'log in' view controller is a child of the TabBar view controller. 如果是这样,那是因为您的“登录”视图控制器是TabBar视图控制器的子级。 Your modal view does not show the TabBar because it's controller is not a child of the TabBar view controller. 您的模式视图不显示TabBar,因为它的控制器不是TabBar视图控制器的子级。

You may want to reconsider the design of you app. 您可能需要重新考虑应用程序的设计。 A modal view controller is usually presented as temporary deviation from the main workflow. 模态视图控制器通常表示为与主要工作流程的暂时偏离。 See the View Controller Programming Guide for iOS - Modal View Controllers 请参阅《适用于iOS的View Controller编程指南- 模态视图控制器》

You could swap things around. 您可以交换周围的东西。 Have the main contents of your app in the TabBar, and upon the app launch, if the user is not already logged in, present your 'log in' view as a Modal View. 在TabBar中拥有您应用的主要内容,并且在应用启动时,如果用户尚未登录,则将您的“登录”视图显示为模态视图。 Then dismiss it once the user logs in. 然后在用户登录后将其关闭。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM