2

我是 xcode 和 ios 开发的新手。我正在学习使用 Brad Larson 在线课程。现在,他不使用故事板来创建界面。在他的委托文件中,他使用代码来加载 rootViewController。

现在,当我创建一个新的单页 ios 项目时,它似乎不是负责加载控制器的 XYZAppDelegate。

我知道在 mainstoryboard.storyboard 文件中,我的 XYZViewController 出现在其中。我只是想知道为什么不是 XYZAppDelegate 负责加载 viewController ?

在 appDelegate 中,didFinishLaunchingWithOptions 方法中没有任何内容,但程序仍然加载?

但是,main.m 文件表明 XYZAppDelegate 是 delegateClassName。

最后,我的问题是,如果不是 AppDelegate ,那么在这种情况下谁负责加载 XYZViewController ?

这些是默认的 xcode 生成文件

主文件

  return UIApplicationMain(argc, argv, nil, NSStringFromClass([XYZAppDelegate class]));

XYZAppDelegate

#import "XYZAppDelegate.h"

@implementation XYZAppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // Override point for customization after application launch.
    return YES;
}

- (void)applicationWillResignActive:(UIApplication *)application
{
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

- (void)applicationDidEnterBackground:(UIApplication *)application
{
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

- (void)applicationWillEnterForeground:(UIApplication *)application
{
    // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
}

- (void)applicationDidBecomeActive:(UIApplication *)application
{
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

- (void)applicationWillTerminate:(UIApplication *)application
{
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

@end
4

1 回答 1

1

答案就在您的 Info.plist 文件中。如果你看,你会看到两个被调用的键Main storyboard file base nameMain storyboard file base name (iPad)它们的值应该是相应设备的故事板文件的名称。如果这些键在启动时存在,操作系统将自动加载情节提要文件并将情节提要中的第一个视图控制器插入应用程序的窗口。Info.plist 键解释的文档UIMainStoryboardFile(原始键称为)。

于 2013-01-11T04:30:42.937 回答