Search code examples
iosobjective-cxcodeuibarbuttonitemibaction

On iphone5 (7.1) simulator, UIBarButtonItem created on StoryBoard not calling IBAction method


i have UIViewController Embedded into UINavigationController

In Xcode 6.1 Storyboard, i dragged a custom UIToolBar onto UIView's bottomside i dragged an UIBarButtonItem onto right side of the custom UIToolBar.

By Ctrl+Drag , i linked UIBarButtonItem to an (IBAction)clickedSave:(UIBarButtonItem *)sender method. When i hover onto plus sign next to method, it emphasizes UIBarButtonItem. And Vice versa. Looks like they are linked.

in simulator 5(8.1) , IBAction works in simulator 5(7.1) , IBAction works not !

i read lots of comments to do it programatically . OK. i'll try it even tough some other people mentioning programmatic approach not working either.

Later, somehow, for test purposes, i managed to think of dragging another UIBarButtonItem onto UINavigationController's UINavigationItem this time. I ctrl+Dragged this new UIBarButtonItem to the same IBAction method.

When hovering over IBAction method's plus sign next to it, this time it emphasizes both UIBarButtonItems of custom UIToolbar's and UINavigationController's UINavigationItem's. Looks like they are both linked.

NavigationControllers UIBarButtonItem works and calls IBAction method on 7.1 Custom UIToolBar's UIBarButtonItem not works on 7.1.

i also have a UITapGestureRecognizer for rootview to let keyboard dismissed when clicked elsewhere rather than UITextFields on root UIView, generated on ViewDidLoad . May it be something about that ?

Does UIBarButtonItem Touch IbAction ever works on xCode 6.1 - Simulator 5(7.1) ? Do we have to do something specific for 7.1 ? Why is UIBarButtonItem of NavigationController working while UIBarButtonItem on custom UIToolBar is not working ?

Here is an image. both UIBarButtonItems created in a similiar fashion. Dragged on to IB. Then by Ctrl+Drag , they have been linked to method Top one is the UINavigationController's UIBarButtonItem Bottom one is the custom UIToolBar's UIBarButtonItem. Bottom one not working on 7.1 enter image description here


Solution

  • i think i found the solution. For a long time, i tried lots of useless stuff. Adding selectors programatically , bla bla bla

    i also had an UITapGestureRecognizer added on viewDidLoad in order to dismiss keypad. it was not letting gestures to reach UIView. Not to UIBarButtonItem Click Event and many more Not to UITableViewCell Select Event.

    This solved my problem: tap.cancelsTouchesInView=NO;

    All of a sudden UITableViewCell Select started to work UIBarButtonItem Click event started to work.

    My problem was occurring only (7.1) Not in (8.1)