当我修改标准 UITabBar 应用程序时,一切都错了
我创建了“新项目”->标签栏应用程序。 然后我从 @interface FirstViewController : UIViewController 更改为 @interface FirstViewController : UINavigationController 。 然后我在 xib 文件中将文件的所有者从 UIViewController 更改为 UINavigationController 。 然后我更新了视图。但我在屏幕上没有看到任何标签。为什么? (我在xib上有一些标签)
I created "New Project" -> Tab Bar Application.
Then i changed from @interface FirstViewController : UIViewController to @interface FirstViewController : UINavigationController.
Then i changed file's owner from UIViewController to UINavigationController in xib file.
Then i updated view. But i don't see any label on the screen. Why? (i have some labels on xib)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为什么你要子类化 UINavigationController 以及你想要完成什么? UINavigationController 不显示它自己的视图,只是显示其他视图控制器视图上的导航栏。此外,UINavigationController 并未设计为子类,因此“此类不适合子类化”。其类参考中的警告。
如果要将视图控制器显示为导航堆栈的一部分,您应该创建 UINavigationController 的实例,将该导航控制器设置为其中一个选项卡的视图控制器,然后将 FirstViewController 的实例推送到 UINavigationController 上。
Why are you subclassing UINavigationController and what are you trying to accomplish? UINavigationController does not display a view of it's own, just the navigation bar over some other view controller's view. In addition UINavigationController was not designed to be subclasses, hence the "This class is not intended for subclassing." warning in its class reference.
If you want to display your view controller as part of a navigation stack you should create an instance of UINavigationController, set that navigation controller as the view controller for one of your tabs, and then push an instance of your FirstViewController onto the UINavigationController.