I have a button on the left side of the navigation bar. I also have a UIButton near that button.
Now when I click the button thats below the navigation bar, in many
It looks like a problem with how you're initializing the UIButton
instance. Typically, we would use [UIButton buttonWithType:custom];
in your situation.
From this answer, they solved a similar question with the following:
UIImage *myImage = [UIImage imageNamed:@"paw.png"];
UIButton *myButton = [UIButton buttonWithType:UIButtonTypeCustom];
[myButton setImage:myImage forState:UIControlStateNormal];
myButton.showsTouchWhenHighlighted = YES;
myButton.frame = CGRectMake(0.0, 0.0, myImage.size.width, myImage.size.height);
[myButton addTarget:self action:@selector(tapped:) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *rightButton = [[UIBarButtonItem alloc] initWithCustomView:myButton];
self.navigationItem.rightBarButtonItem = rightButton;
[rightButton release];
[myButton release];
It's not the code you're looking for, but it shows you how to correctly instantiate a UIButton
instance. Hopefully that will sort out the problems you're having.