简体   繁体   English

确定哪个UIViewController首先运行

[英]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.

相关问题 确定第一次出现UIViewController - Determine the first time a UIViewController appears iPhone-以编程方式确定故事板上的哪个UIViewController调用了我的课程? - iphone - Programmatically determine which UIViewController on Storyboard called my class? 确定是否存在UIViewController子类的实例 - Determine if instance of UIViewController subclass exists 哪个UIViewController称为popViewControllerAnimated :? - Which UIViewController called popViewControllerAnimated:? 确定UIViewController是否由于应用程序退出而关闭? - Determine if UIViewController is closing due to application exit? 如何在不导入第一个UIViewController类的情况下从UINavigationController中的另一个UIViewController手动取消分配UIViewController? - How can I dealloc manually UIViewController from another UIViewController in UINavigationController without import the first UIViewController class? 第一次在情节提要中提示另一个UIViewcontroller - Prompt another UIViewcontroller at storyboard at the first time 如何基于首次加载来加载TabBarController或UIViewController - How to load TabBarController or UIViewController based on first load UIViewController-无法成为第一响应者 - UIViewController - can't become first responder 试图回到应用程序的第一个UIViewController - Trying to Get Back to the First UIViewController of the App
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM