2013-10-28 57 views
1

這是非常奇怪的!它簡單的東西,這就是爲什麼我不明白。下面顯示我的課程。無法識別的選擇器發送到實例怪異

#import <UIKit/UIKit.h> 

@interface LogInViewController : UIViewController 
- (IBAction)loginButtonPressed:(id)sender; 

@end 

#import "LogInViewController.h" 

@interface LogInViewController() 

@end 

@implementation LogInViewController 

- (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 from its nib. 
} 

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


// 

- (IBAction)loginButtonPressed:(id)sender 
{ 
    NSLog(@"login Button Pressed"); 
} 

每當我點擊按鈕雖然它會拋出這個?

loginButtonPressed:]:無法識別的選擇發送到實例 0x15e3bf60 2013年10月28日11:23:24.249頭痛MBL [1352:60B] * 終止應用程序由於未捕獲的異常 'NSInvalidArgumentException' 的,原因是: 「 - [__ NSSetM loginButtonPressed:]:無法識別的選擇發送到實例 0x15e3bf60」 *第一擲調用堆棧:

伊夫檢查,該按鈕被正確地發送「內部潤色登錄inButtonPressed:」

幫助!三江源:)

這裏是我的視圖控制器連接到我的主屏幕

進口

@interface ViewController : UIViewController 

@property (strong) IBOutlet UIView *loginView; 

- (void)viewDidLoad 
{ 

    LogInViewController *logIn = [[LogInViewController alloc] initWithNibName:@"LogInViewController" bundle:nil]; 
    [self.loginView addSubview:logIn.view]; 
    [self.loginView setClipsToBounds:YES]; 
} 
+0

您使用ARC嗎? 。看看這個問題http://stackoverflow.com/questions/2455161/unrecognized-selector-sent-to-instance?rq=1 – Priyatham51

+0

也就在你的按鈕,看看它是否只連接到一個'IBAction' 。如果您更改了方法名稱,它可能仍然指向舊名稱。 – Priyatham51

+0

請顯示您的代碼,聲明對象爲LogInViewController – manujmv

回答

1

看起來像內存問題。如果你使用ARC,你應該保持對視圖控制器的強大參考。如果您正在使用手動內存管理,可能視圖控制器已被過度發佈。要找到問題,您可以將NSZombieEnabled標誌添加到方案中或使用Instruments with Zombie。

+0

嗨,我正在使用ARC,並且已經使用了對uview的強烈參考,這是你的意思。 iv編輯上面的帖子來展示這一點,以及我如何設置主屏幕。謝謝 – Ryan

+0

@Ryan不,他的意思是保持對視圖**控制器**的強烈參考,即您在問題中顯示的類。 – JeremyP

0

只是一個建議,但你是否檢查IB中按鈕的事件連接。您是否可以將連接切換到您已刪除操作方法的另一個VC。檢查控制檯 loginButtonPressed:]:無法識別的選擇器發送到實例0x15e3bf60 什麼是0x15e3bf60(po 0x15e3bf60)。

相關問題