ios - 为什么我的应用程序在 (BOOL) 应用程序 :(UIApplication *) in the appDelegate? 下没有任何代码

标签 ios methods appdelegate

据我所知,当我打开 AppDelegate.m 文件时,它应该包含与此类似的代码。

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:  
(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.viewController = [[ViewController alloc] initWithNibName:@"ViewController" 
bundle:nil];
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];

return yes;

但是当我打开我的时,里面只有评论和

return yes;

此外,当我手动输入所有代码时,它会告诉我 self.viewController 行在类型为“AppDelegate *”的对象上找不到属性“viewController”,并且还针对下一个 self 实例在其下方的 2 行.viewController.

为什么会发生这种情况,我该如何解决?

最佳答案

如果您使用 Storyboard 创建了项目(这在一段时间内是唯一的选择),则不需要该代码。 UIApplicationMain 创建您的 UIWindow,将其分配给您的应用程序委托(delegate)的 window 属性,并从 Storyboard加载窗口的 Root View Controller 。

关于ios - 为什么我的应用程序在 (BOOL) 应用程序 :(UIApplication *) in the appDelegate? 下没有任何代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24090951/

相关文章:

ios - 使用 self.window?.makeKeyAndView() 时的 EXC_BREAKPOINT

ios - 在 iOS 中处理不同的 URL Scheme(Facebook 和 Instagram)

ios - didBecomeActive 取消暂停游戏

IOS/objective-C : returning to main thread

iOS - 检查 [CGPoint] 画一条直线

ios - 无法为 AVCaptureVideoPreviewLayer 设置边界

ios - 使用 xcode 播放声音

android - 从 View 中调用电话

java - 调用方法并传递对象引用并使用相同的引用捕获返回

xcode - 从Sprite套件中的类调用方法?