Search code examples
iosinterface-builderuibarbuttonitemuitoolbar

UIBarButtonItem triggers action only when pressed for long enough


I have a few simple UIBarButtonsItems(no customization other than changing style, color and alpha). Everything was working perfectly fine for some time. But now I need to press BarButton for a long time(4-5 seconds) before the action is triggered.

I just moved toolbar around and changed color and alpha after which this started happening. I don't exactly understand what caused this change of behavior.

I used interface builder to build the view and assigned action to UIBarButtonItems by Ctrl+Dragging.

I tried looking up a lot both on google and so. Most of the questions are about UIBarButtons not responding at all. Still I tried the solution of cleaning build of project and Xcode cache. But nothing changed.

Could someone help me with this?


Solution

  • I realized my mistake. I had two events getting triggered in same space in view. First was to reveal toolbar(i.e. increase its alpha) when tapped in particular area of the view and second one was of course button tap event for UIBarButtonItem. When tapped in that area the first event got triggered and eventually when pressed for long it also fired the second event once the toolbar was visible(if toolbar was invisible before).
    Sorry to bother you all.