开发者

UIBarButtonItem set Action touch up inside by programming

开发者 https://www.devze.com 2023-03-16 16:21 出处:网络
in my project , i kept a UIBarbuttonItem by programmingand it is working fine but my problem is. if i click on that it is notblinking like normal UIButton Touch up inside event like.

in my project , i kept a UIBarbuttonItem by programming and it is working fine but my problem is. if i click on that it is not blinking like normal UIButton Touch up inside event like. below how i implemented.

UIBarButtonItem *todayButton = [[UIBarButto开发者_C百科nItem alloc] initWithTitle:@"Today"
         style:UIBarButtonSystemItemFlexibleSpace 
        target:self action:@selector(showTodaysDate)];
[toolBarItemArr addObject:todayButton];
[todayButton release];

how to implement touchup event programmatically


UIBarButtonItem Doesn't have any touchupInside event. It can not behave like a UIButton. It also doesn't have selected or disable image. It only have enable or disable state. So you can't replicate it like UIButton.


I think you want the UIBarButtonItem to glow, when you touch on it. Actually it is a behavior of UIButton, not UIBarButtonItem. UIButton has a property showsTouchWhenHighlighted which makes the button to glow on touch, if set YES. There is no way to make a UIBarButtonItem to behave like this.


You should change the Style into UIBarButtonItemStyleBordered and You don't want to implement any event for the Barbutton Items. Basically Bar button Items works for touch up inside event.

0

精彩评论

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