Pheepster
Pheepster

Reputation: 6347

UIBarButtonItem clickable on left but not on right of navigation controller

This is really strange behavior and I'm only experiencing it in iOS8 iPads. I have a UIBarButtonItem that needs to go on the right side of the navigation bar. Here is my code to set the button:

        UIBarButtonItem *btnAttOpen = [[UIBarButtonItem alloc] init];
        [btnAttOpen setAction:@selector(addAttClick:)];
        [btnAttOpen setImage:[UIImage imageNamed:@"addAtt"]];
        [btnAttOpen setTarget:self];
        [self.navigationItem setRightBarButtonItem:btnAttOpen];

When I do this, the btnAttOpen button appears where it should but is not clickable. It simply behaves as if it were a static image. The strangest part of this is if I replace setRightBarButtonItem: with setLeftBarButtonItem: the button behaves as intended.

This doesn't make sense to me. Has anyone seen this kind of behavior? Any ideas as to why this may be occurring? Thanks!

Upvotes: 1

Views: 85

Answers (1)

dmirkitanov
dmirkitanov

Reputation: 1396

If something doesn't want to react appropriately to touches, often the problem is that one of the parent view's frames has incorrect size, which doesn't fully cover the child's frame.

You could check them, for example, by printing out view hierarchy in gdb: po [[UIWindow keyWindow] recursiveDescription]

Upvotes: 1

Related Questions