I have a navigation controller which I've added a UIButton
to the navigation bar, but there's something wrong with it. Even if I tap way outside of the button, it still calls it's action.
This is how I create and add the button:
UIButton *backBtn = [UIButton buttonWithType:UIButtonTypeCustom];
[backBtn setImage:[UIImage imageNamed:@"btn_back.png"] forState:UIControlStateNormal];
[backBtn addTarget:self action:@selector(backPressed:) forControlEvents:UIControlEventTouchUpInside];
[backBtn setFrame:CGRectMake(0, 0, 70, 30)];
//[backBtn setFrame:CGRectMake(20, 7, 70, 30)];
self.navigationItem.leftBarButtonItem = [[[UIBarButtonItem alloc] initWithCustomView:backBtn] autorelease];
Here's the tap range of the button: