如何更改应用启动时加载的默认View Controller? [英] How to change the default View Controller that is loaded when app launches?

查看:141
本文介绍了如何更改应用启动时加载的默认View Controller?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序,比如'MyApp',默认情况下,只要应用程序启动,它就会加载视图控制器'MyAppViewController'。后来,我在项目中添加了一个新的视图控制器'NewViewControler'。

I have an application, say 'MyApp', which by default loads the view controller 'MyAppViewController' whenever the application launches. Later, I added a new view controller 'NewViewControler' to the project.

我现在希望'NewViewController'成为我的默认视图控制器,它会在应用启动时加载。

I now want the 'NewViewController' to be my default view controller which loads when the app launches.

请告诉我在项目中需要做些什么改变才能实现这一目标。

Please let me know what changes I need to make in my project to achieve this.

推荐答案


  1. 打开 MainWindow.xib 并用NewViewController替换MyAppViewController。

  2. 在你的应用委托类,将MyAppViewController的属性替换为NewViewController的属性。将NewViewController连接到Interface Builder中的新插座。

  3. 应用程序中:didFinishLaunchingWithOptions:将NewViewController的视图添加到窗口而不是MyAppViewController的视图。

  1. Open MainWindow.xib and replace MyAppViewController with NewViewController.
  2. In your app delegate class, replace the property for MyAppViewController with one for NewViewController. Connect NewViewController to its new outlet in Interface Builder.
  3. In application:didFinishLaunchingWithOptions: add NewViewController's view to the window instead of MyAppViewController's view.

这篇关于如何更改应用启动时加载的默认View Controller?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆