Я пытаюсь добавить действие к 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;
Что происходит?