清洁项目xcode后的SIGABRT

时间:2012-05-31 12:50:29

标签: uiviewcontroller interface-builder

我的代码在我的iPhone 5.0模拟器上进行了数天和数周的代码更改并运行正常,直到我清理它为止。

现在它已经死在这一行[window addSubview:self.viewController.view];

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    

    [self.window addSubview:self.viewController.view];   // dies here
    [self.window makeKeyAndVisible];

    return YES;
}

self.viewController存在,但self.viewController.view没有。

<code>self.viewController.view</code> does not exist

编辑添加我的AppDelegate.h

#import <UIKit/UIKit.h>

@class MainMenu;

@interface yomikakiAppDelegate : NSObject <UIApplicationDelegate> {
    UIWindow *window;
    MainMenu *viewController;
}

@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet MainMenu *viewController;

@end

我认为IB必定已经失去了联系,但我不确定如何重新连接它。

我将MainMenu.xib Referencing Outlet视图设为File的所有者,但是没有修复它。

This didn't help but I hoped it would!!

如何让我的viewController获取其视图?

编辑以添加我的nib文件的Identity Inspector的屏幕截图:

screenshot of .xib File's Owner Identity Inspector

2 个答案:

答案 0 :(得分:2)

您好,为什么要这样做?

[window addSubview:self.viewController.view];

试试这个

[self.window addSubview:self.viewController.view];
 [self.window makeKeyAndVisible];
 return YES;

文件所有者必须链接到ViewController的视图。

答案 1 :(得分:0)

你不能重命名你的UIViewControllers。

几周前,我将原来的firstProjectViewController重命名为MainMenu,允许其名称与FooMenu和BarMenu(其兄弟的名字)相适应。

我不知道为什么该项目在那时继续编译,但问题在我几天前清理我的代码之后才变得明显。

所以我选择的答案在大多数情况下都是正确的,但为了自己解决,我需要将“MainMenu”的每次出现都改为“firstProjectViewController”。

相关问题