[英]Determine which UIViewController runs first
I started to learn objective-c and ios programming.I have two View Controller which are named MainViewController and GameViewController,also there are two xib files in my project.I connected xib files with the ViewController's.Totally Here are my files: 我开始学习Objective-C和ios编程。我有两个名为MainViewController和GameViewController的View Controller,在我的项目中还有两个xib文件。我将xib文件与ViewController的文件连接在一起。以下是我的文件:
View Controllers, 查看控制器,
AppDelegate.h
AppDelegate.m
MainViewController.h
MainViewController.m
GameViewController.h
GameViewController.m
and xibs, 和小臂
Main.xib
Game.xib
I choose Main.xib as main interface in the project options.I'm trying to understand questions below,when i run this application first main.m runs.Thats okay. 我在项目选项中选择Main.xib作为主界面。当我第一次运行main.m运行该应用程序时,我试图理解以下问题。
After that does the AppDelegate class runs?How xcode determines which View Controller will run first? 之后,AppDelegate类将运行?xcode如何确定哪个View Controller首先运行?
With this project when i run,there is only black screen.Can anyone help me about an ios application's run order? 当我运行该项目时,只有黑屏。有人可以帮助我了解ios应用程序的运行顺序吗?
Xcode doesn't determine anything, it's entirely up to you to set up your UI after Xcode不会决定任何事情,这完全取决于您在之后设置UI
-application:didFinishLaunchingWithOptions:launchOptions
is called by the system. 由系统调用。 Below is an example where ExampleViewController
is initialized first: 下面是一个示例,其中ExampleViewController
被初始化:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.viewController = [[ExampleViewController alloc] initWithNibName:@"ExampleViewController" bundle:nil];
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
return YES;
}
The Application initialization flow is: 应用程序初始化流程为:
main() -> AppDelegate (or whatever class has been designated the delegate) -> initial view controller
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.