I have put a button over a toolbar.But when i press that button,my selector is not called and application crashes giving following error
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '* -[ChatViewController changeButtonImage]: unrecognized selector sent to instance 0x119570'
here is my code..
UIToolbar *toolBar=[[UIToolbar alloc]initWithFrame:CGRectMake(5,0,310,44)];
UIBarButtonItem *changeImagebtn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemOrganize
target:self
action:@selector(changeButtonImage)];
UIBarButtonItem *flexItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace
target:nil
action:nil];
UIBarButtonItem *textField = [[UIBarButtonItem alloc] initWithCustomView:peerName];
NSArray *items = [NSArray arrayWithObjects:textField,flexItem,flexItem,changeImagebtn,nil];
[toolBar setItems:items animated:NO];
[self.view addSubview:toolBar];
My action block is ----
-(void)changeButtonImage:(id)sender
{
UIImagePickerController *pic=[[UIImagePickerController alloc] init];
pick=pic;
pick.delegate=self;
pick.sourceType=UIImagePickerControllerSourceTypePhotoLibrary;
[self presentModalViewController:pick animated:YES];
}
where am i wrong?Please suggest me...