[英]Determine which UIViewController runs first
我開始學習Objective-C和ios編程。我有兩個名為MainViewController和GameViewController的View Controller,在我的項目中還有兩個xib文件。我將xib文件與ViewController的文件連接在一起。以下是我的文件:
查看控制器,
AppDelegate.h
AppDelegate.m
MainViewController.h
MainViewController.m
GameViewController.h
GameViewController.m
和小臂
Main.xib
Game.xib
我在項目選項中選擇Main.xib作為主界面。當我第一次運行main.m運行該應用程序時,我試圖理解以下問題。
之后,AppDelegate類將運行?xcode如何確定哪個View Controller首先運行?
當我運行該項目時,只有黑屏。有人可以幫助我了解ios應用程序的運行順序嗎?
Xcode不會決定任何事情,這完全取決於您在之后設置UI
-application:didFinishLaunchingWithOptions:launchOptions
由系統調用。 下面是一個示例,其中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;
}
應用程序初始化流程為:
main() -> AppDelegate (or whatever class has been designated the delegate) -> initial view controller
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.