2013-08-04 41 views
0

我對這個Objective-C編程完全陌生。我最近正在製作一個非常簡單的應用程序,我無法找到爲什麼當我嘗試在第二個控制器視圖中定義UI項目時該應用程序無法工作。我不斷接收到該錯誤消息:SIGABRT-這個類不是關鍵值編碼兼容密鑰

「2013年8月4日02:38:45.488 Cheerup [43957:C07] *終止應用程序由於未捕獲的異常 'NSUnknownKeyException',原因:「[setValue方法:forUndefinedKey:]:這個類不是關鍵值welcomeMsg的關鍵值編碼。「 *第一擲調用堆棧: (0x1c91012 0x10cee7e 0x1d19fb1 0xb7ae41 0xafc5f8 0xafc0e7 0xb26b58 0x230019 0x10e2663 0x1c8c45a 0x22eb1c 0xf37e7 0xf3dc8 0xf3ff8 0xf4232 0xffc25 0x2ff3a3 0xfcee3 0xfd167 0xfd1a7 0x4690a2 0x45ab99 0x45ac14 0x10e2705 0x162c0 0x16258 0xd7021 0xd757f 0xd66e8 0x45cef 0x45f02 0x23d4a 0x15698 0x1becdf9 0x1becad0 0x1c06bf5 0x1c06962 0x1c37bb6 0x1c36f44 0x1c36e1b 0x1beb7e3 0x1beb668 0x12ffc 0x282d 0x2755) 的libC++ abi.dylib:終止叫做拋出異常 (LLDB)「

是有一些問題Appdeligate?

以下是我的兩位視圖控制器:

MenuViewController.h

#import <UIKit/UIKit.h> 

@interface MenuViewController : UIViewController{ 

} 

@property IBOutlet UIButton *Botton1; 
@property IBOutlet UIButton *Botton2; 

@end 

MenuViewController.m

#import "MenuViewController.h" 

@interface MenuViewController() 

@end 

@implementation MenuViewController 

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil 
{ 
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; 
    if (self) { 
     // Custom initialization 
    } 
    return self; 
} 

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 
    // Do any additional setup after loading the view. 
} 

- (void)didReceiveMemoryWarning 
{ 
    [super didReceiveMemoryWarning]; 
    // Dispose of any resources that can be recreated. 
} 

@end 

AfterMenuViewController.h

#import <UIKit/UIKit.h> 


@interface AfterMenuViewController : UIViewController{ 

    IBOutlet UILabel *WelcomeMsg; 
    IBOutlet UIButton *Back; 
} 


@end 

AfterMenuViewController.m

#import "AfterMenuViewController.h" 


@interface AfterMenuViewController() 

@end 

@implementation AfterMenuViewController 

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil 
{ 
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; 
    if (self) { 
     // Custom initialization 
    } 
    return self; 
} 

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 
    // Do any additional setup after loading the view. 


} 

- (void)didReceiveMemoryWarning 
{ 
    [super didReceiveMemoryWarning]; 
    // Dispose of any resources that can be recreated. 
} 


@end 

有什麼想法? THanks Kamyar

回答

1

你的錯誤說:welcomeMsg和你的代碼說WelcomeMsg。命名區分大小寫。看起來你連接後可能已經重新命名了一個插座。嘗試刪除連接並重新連接。

請注意,按照慣例,實例變量和屬性以小寫字母開頭,類名以大寫字母開頭。所以welcomeMsg是正確的。

0

我認爲IBOutlets存在問題。試試這個

#import <UIKit/UIKit.h> 


@interface AfterMenuViewController : UIViewController{ 

    // comment this 
    // IBOutlet UILabel *WelcomeMsg; 
    // IBOutlet UIButton *Back; 
} 

@property (weak, nonatomic) IBOutlet UILabel *WelcomeMsg; 
@property (weak, nonatomic) IBOutlet UIButton *Back; 

@end

相關問題