开发者

How to restrict rightBarButtonItem size in UINavigationBar?

开发者 https://www.devze.com 2022-12-28 08:40 出处:网络
I create a rightBarButtonItem with this method : - (UIBarButton开发者_JS百科Item *)customBarButtonWithSelector:(SEL)callback {

I create a rightBarButtonItem with this method :

- (UIBarButton开发者_JS百科Item *)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 ?


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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消