简体   繁体   English

如何隐藏iPhone标签栏?

[英]How to hide an iPhone Tab Bar?

I have a small multiview app. 我有一个小型多视图应用程序。 It consists of a UITabBarController with a nav controller in each tab. 它由一个UITabBarController组成,每个选项卡中都有一个导航控制器。 What I want is to show a UIImageView when a user shakes the device. 我想要的是在用户摇动设备时显示UIImageView After I've implemented the loading of the UIImageView , I faced a problem-the image was only 2/3 of the screen because of the tab and nav bars. 在我实现了UIImageView的加载后,我遇到了一个问题 - 因为选项卡和导航栏,图像只占屏幕的2/3。 I managed to hide the nav bar but I'm still stuck with the tab bar. 我设法隐藏了导航栏,但我仍然坚持使用标签栏。 I tried many solutions such as [tabBar setHidden: YES]; 我尝试了很多解决方案,例如[tabBar setHidden: YES]; but I get errors "tabBar undeclared", although I've imported the AppDelegate, where the tabBar was defined. 但我得到错误“tabBar未声明”,虽然我已经导入了定义tabBar的AppDelegate。

Thanks in advance! 提前致谢!

Try setting 尝试设置

myViewController.hidesBottomBarWhenPushed = YES;

when you create your UIImageView. 当您创建UIImageView时。 When you push it on to the view stack the UITabBar will hide automatically, and it will be restored automatically when you pop or dismiss the controller. 当您将其推入视图堆栈时,UITabBar将自动隐藏,当您弹出或关闭控制器时,它将自动恢复。 No need for the application delegate. 不需要申请代表。

If you want to show a full screen view, it is best to use a modal view controller. 如果要显示全屏视图,最好使用模态视图控制器。 This way you do have to worry about hiding/showing navigation items. 这样您就不必担心隐藏/显示导航项。 Take a look at: 看一眼:

http://developer.apple.com/iphone/library/featuredarticles/ViewControllerPGforiPhoneOS/ModalViewControllers/ModalViewControllers.html http://developer.apple.com/iphone/library/featuredarticles/ViewControllerPGforiPhoneOS/ModalViewControllers/ModalViewControllers.html

to get started. 开始。

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

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