昨晚我去测试我的 iOS 应用程序时,它在启动时崩溃了。我什至没有研究导致崩溃的 Nib 。无论如何,这是错误代码:
2/29/12 10:32:05.291 AM Safe Flight: *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIApplication 0xdd496f0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key Airport1.'
*** First throw call stack:
(0x2873052 0x33add0a 0x2872f11 0x1ae2032 0x1a53f7b 0x1a53eeb 0x1a6ed60 0x136191a 0x2874e1a 0x27de821 0x136046e 0x1362010 0x114214a 0x1142461 0x11417c0 0x1150743 0x11511f8 0x1144aa9 0x37b7fa9 0x28471c5 0x27ac022 0x27aa90a 0x27a9db4 0x27a9ccb 0x11412a7 0x1142a9b 0x3710 0x2f35)
Airport1 只是一个标签,其中有一个 正确 连接到它的 IBOutlet。另外,如果我删除连接,错误只是与下一个有连接的项目有关。
另外,我的 FileOwners 类正确设置为适当的 viewController。
// MasterViewController.h
#import <UIKit/UIKit.h>
#import "MobclixAds.h"
@class DataViewController;
@class EditViewController;
@class SearchViewController;
@interface MasterViewController : UIViewController{
UILabel *Airport1;
UILabel *Airport2;
UILabel *Airport3;
UILabel *Airport4;
UILabel *Airport5;
UILabel *Airport6;
UILabel *Airport7;
UILabel *Airport8;
UILabel *Airport9;
UIButton *Airport1B;
UIButton *Airport2B;
UIButton *Airport3B;
UIButton *Airport4B;
UIButton *Airport5B;
UIButton *Airport6B;
UIButton *Airport7B;
UIButton *Airport8B;
UIButton *Airport9B;
MobclixAdView* adView;
}
@property (strong, nonatomic) DataViewController *dataViewController;
@property (strong, nonatomic) EditViewController *editViewController;
@property (strong, nonatomic) SearchViewController *searchViewController;
@property (nonatomic, retain) IBOutlet UILabel *Airport1;
@property (nonatomic, retain) IBOutlet UILabel *Airport2;
@property (nonatomic, retain) IBOutlet UILabel *Airport3;
@property (nonatomic, retain) IBOutlet UILabel *Airport4;
@property (nonatomic, retain) IBOutlet UILabel *Airport5;
@property (nonatomic, retain) IBOutlet UILabel *Airport6;
@property (nonatomic, retain) IBOutlet UILabel *Airport7;
@property (nonatomic, retain) IBOutlet UILabel *Airport8;
@property (nonatomic, retain) IBOutlet UILabel *Airport9;
@property (nonatomic, retain) IBOutlet UIButton *Airport1B;
@property (nonatomic, retain) IBOutlet UIButton *Airport2B;
@property (nonatomic, retain) IBOutlet UIButton *Airport3B;
@property (nonatomic, retain) IBOutlet UIButton *Airport4B;
@property (nonatomic, retain) IBOutlet UIButton *Airport5B;
@property (nonatomic, retain) IBOutlet UIButton *Airport6B;
@property (nonatomic, retain) IBOutlet UIButton *Airport7B;
@property (nonatomic, retain) IBOutlet UIButton *Airport8B;
@property (nonatomic, retain) IBOutlet UIButton *Airport9B;
@property(nonatomic,retain) IBOutlet MobclixAdView* adView;
@end
和
// MasterViewController.m
#import "MasterViewController.h"
#import "DataViewController.h"
#import "EditViewController.h"
#import "SearchViewController.h"
@implementation MasterViewController
@synthesize dataViewController = _dataViewController;
@synthesize editViewController = _editViewController;
@synthesize searchViewController = _searchViewController;
@synthesize Airport1, Airport2, Airport3, Airport4, Airport5, Airport6, Airport7, Airport8, Airport9;
@synthesize Airport1B, Airport2B, Airport3B, Airport4B, Airport5B, Airport6B, Airport7B, Airport8B, Airport9B;
@synthesize adView;
- (id)initWithNibNameNSString *)nibNameOrNil bundleNSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
self.title = @"Safe Flight";
self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle"Back" style:UIBarButtonItemStylePlain target:nil action:nil];
}
return self;
}
我的代码有问题吗?还是 Xcode 本身?我重新启动了 Xcode 和模拟器,甚至做了一个“干净”的构建(听起来会有所帮助......)
谢谢,
安德鲁
编辑这是我的 AppDelegate,我正在为窗口设置正确的 xib
- (BOOL)applicationUIApplication *)application didFinishLaunchingWithOptionsNSDictionary *)launchOptions
{
[Mobclix start];
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
MasterViewController *masterViewController = [[MasterViewController alloc] initWithNibName"MasterViewController" bundle:nil];
self.navigationController = [[UINavigationController alloc] initWithRootViewController:masterViewController];
self.window.rootViewController = self.navigationController;
[self.window makeKeyAndVisible];
return YES;
}
问题解决了!!!
由于一些愚蠢的垃圾邮件过滤器,我无法回答自己的问题...我可以发布问题的图片...但它已修复!
但是这里是问题的链接click here
Best Answer-推荐答案 strong>
发现问题!!我现在觉得有点傻;)但无论如何,这是问题的截图!
关于ios - Xcode 中的 IB 连接崩溃,我们在Stack Overflow上找到一个类似的问题:
https://stackoverflow.com/questions/9503536/
|