gpt4 book ai didi

iphone - Xcode 默认一页 ios 项目 - 为什么代理不负责加载 Controller

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:45:46 26 4
gpt4 key购买 nike

我是 xcode 和 ios 开发的新手。我正在使用 Brad Larson 在线类(class)学习。现在,他不使用 Storyboard来创建界面。在他的委托(delegate)文件中,他使用代码加载 rootViewController。

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

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

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

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

最后,我的问题是,如果不是 AppDelegate,谁负责加载 XYZViewController?

这些是xcode默认生成的文件

主.m

  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

最佳答案

答案就在您的 Info.plist 文件中。如果你看,你会看到两个名为 Main storyboard file base nameMain storyboard file base name (iPad) 的键值应该是你的 Storyboard的名称相应设备的文件。如果这些键在启动时存在,操作系统将自动加载 Storyboard文件并将 Storyboard中的第一个 View Controller 插入到应用程序的窗口中。 Docs here对于 Info.plist key 解释(原始 key 称为 UIMainStoryboardFile)。

关于iphone - Xcode 默认一页 ios 项目 - 为什么代理不负责加载 Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14271589/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com