這是非常奇怪的!它簡單的東西,這就是爲什麼我不明白。下面顯示我的課程。無法識別的選擇器發送到實例怪異
#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];
}
您使用ARC嗎? 。看看這個問題http://stackoverflow.com/questions/2455161/unrecognized-selector-sent-to-instance?rq=1 – Priyatham51
也就在你的按鈕,看看它是否只連接到一個'IBAction' 。如果您更改了方法名稱,它可能仍然指向舊名稱。 – Priyatham51
請顯示您的代碼,聲明對象爲LogInViewController – manujmv