How to restrict rightBarButtonItem size in UINavigationBar?

拥有回忆 提交于 2019-12-23 03:26:28

问题


I create a rightBarButtonItem with this method :

- (UIBarButtonItem *)customBarButtonWithSelector:(SEL)callback {
 UIButton *customButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
 customButton.bounds = CGRectMake(0, 0, 30.0f, 30.0f);
 return [[[UIBarButtonItem alloc] initWithCustomView:customButton] autorelease];
}

At execution time the selector is fired when the bar is touched outside the button (near the middle).

Is there a way to restrict the event responder in the defined bounds or in a acceptable range ?


回答1:


Try putting a fixed space before the button in the array of bar button items.




回答2:


I have found the solution at http://osmorphis.blogspot.com/2009/05/multiple-buttons-on-navigation-bar.html Really helpfull, don't forget to subclass UIToolBar.



来源:https://stackoverflow.com/questions/2712100/how-to-restrict-rightbarbuttonitem-size-in-uinavigationbar

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!