문제

I've created a custom button as an NavigationItem at the rightBarBuuttonItem. It works well, but when I click outside the button, for example a little down of the button, it still works. Here is my code

fetchButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 30, 30)];
[fetchButton setImage:[UIImage imageNamed:@"quanse.png"] forState:UIControlStateNormal];
[fetchButton addTarget:self action:@selector(searchDataByColor) forControlEvents:UIControlEventTouchUpInside];
self.navigationItem.rightBarButtonItem =[[UIBarButtonItem alloc] initWithCustomView:fetchButton]; 

Anybody who can tell me, what can I do to fix this bug?

도움이 되었습니까?

해결책

What you are describing is actually the normal behavior of the UIButton. The actual touchable area extends beyond the visible borders of the button. You can see this behavior in Apple's own apps.

Normally this is a convenience for the user, but if you find it undesirable in your app, there's a possible workaround solution in this prior question:

UINavigationItem Back Button touch area too large

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top