Q:

Creating custom buttons for UIBarButton, selector throwing exception

I am creating a custom button with its own image, and assigning it to the rightbarbutton of a nabvigationcontroller I have. The problem is that when the user clicks on the button I get an exceptoin about my controller not recognizing that selctor??
UIImage* image1 = [UIImage imageNamed:@"someImage.png"];
CGRect imgRect = CGRectMake(0, 0, image1.size.width/1.8, image1.size.height/1.8);
UIButton *myButton = [[UIButton alloc] initWithFrame:imgRect];
[myButton setBackgroundImage:image1 forState:UIControlStateNormal];
[myButton addTarget:self action:@selector(nextScreenButtonAction)   forControlEvents:UIControlEventTouchUpInside];

UIBarButtonItem *barButton =[[UIBarButtonItem alloc] initWithCustomView:myButton];
[self.navigationItem setRightBarButtonItem:myButton];
self.navigationController.navigationBarHidden = false;

A:

May be this is the problem nextScreenButtonAction change it to 
[myButton addTarget:self action:@selector(nextScreenButtonAction:) forControlEvents:UIControlEventTouchUpInside]

In your method definition you be passing and argument like 
-(IBAction) nextScreenButtonAction:(id)sender
{
} 

so in the addTarget you need to specify a colon(:) to indicate parameter

