UIButton にアクションを追加しようとしていますが、例外が発生し続けます:
キャッチされない例外 'NSInvalidArgumentException' によるアプリの終了、理由: '[UIImageView addTarget:action:forControlEvents:]: 認識されないセレクターがインスタンス 0x595fba0 に送信されました'
これが私のコードです:
- (void)viewDidLoad
{
[super viewDidLoad];
UIImage *myIcon = [UIImage imageNamed:@"Icon_Profile"];
self.profileButton = (UIButton*)[[UIImageView alloc] initWithImage:myIcon];
[self.profileButton addTarget:self action:@selector(profileButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *buttonItem = [[[UIBarButtonItem alloc] initWithCustomView:profileButton] autorelease];
NSArray *toolbarItems = [[NSArray alloc] initWithObjects:buttonItem, nil];
[self setToolbarItems:toolbarItems animated:NO];
//[toolbarItems release];
//[profileButton release];
}
次に、同じViewコントローラーにこのメソッドがあります:
-(void)profileButtonPressed:(id)sender{
}
そして、私が持っているヘッダーに
-(IBAction)profileButtonPressed:(id)sender;
どうしたの?