创建启动时不显示的导航控制器
我想做这件简单的事情:创建一个 uinavigationcontroller 但在启动时不会显示。假设我想要一个带有“Go”按钮的欢迎屏幕,该按钮可通往 uinavigationcontroller。在我看到的所有示例中,导航控制器似乎立即出现。我应该怎样做呢?
谢谢!
I want to do this simple thing: create a uinavigationcontroller but that doesnt show up on launch. Let's say I want to have a welcome screen with a "Go" button that leads to the uinavigationcontroller. In all the examples that I have seen it looks like the navigationcontroller appears right away. How should I go about doing that?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果“显示”是指使用没有可见足迹的导航控制器,那就很简单。只需在根视图控制器中执行此操作:
对于子视图控制器,您需要执行类似的操作才能在导航栏出现时显示它们。
对于具有主菜单的应用程序来说,这是一种非常常见的技术,您不想在主菜单视图中显示导航栏。
If by "show up" you mean using a navigation controller with no visible footprint, that's easy. Simply do this in the root view controller:
For the child view controllers, you need to do something similar in order to display the navigation bar when they appear.
This is a pretty common technique for apps with main menus where you don't want to display a navigation bar in the main menu view.
显示导航控制器视图的机制发生在应用委托中的
-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions;
方法中。 NC 被添加为窗口的 rootViewController。如果你想显示另一个,只需将你的自定义视图控制器设置在 NC 的位置,然后在按下按钮时调用的操作方法中切换两个视图控制器(用 NC 替换第一个自定义视图控制器)。< br>
假设 myCustomController 定义了一个名为 touchButton 的 UIButton 属性:
现在在您的应用程序委托中编写一个操作方法:
The mecanic of displaying the navigation controller's view takes place in the
-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions;
method, in the app delegate. There the NC is added as the rootViewController of the window.If you want to display another one, just set your custom view controller right in place of the NC and then switch the two view controllers (replace the first custom view controller with the NC) in the action method called when the button is pressed.
Assuming
myCustomController
defines aUIButton
property calledtouchButton
:Now write in your app delegate an action method :
在显示隐藏导航栏的视图控制器中,在其他显示导航栏中
希望这会有所帮助
in viewcontroller that shows go hide navigation bar and in other show navigation bar
hope this will help