0

I have created a right action bar item button using the following code. This code is working fine below iOS 11, but not working on iOS 11.

self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:NSLocalizedString(@"SAVE", nil) style:UIBarButtonItemStylePlain target:self action:@selector(updateButtonTapped)];
Tamás Sengel
  • 55,884
  • 29
  • 169
  • 223
Deepak Sharma
  • 45
  • 1
  • 6

3 Answers3

1

I noticed the same thing in Beta 6. Not a good solution but for me it works if you add it in viewDidAppear instead of viewDidLoad.

bullsAI
  • 35
  • 1
  • 7
0

I just tried this out and all I was missing was a

navigationBar.sizeToFit()

so navigationBar = CGRect(x: 0, y: 0, width: view.bounds.width, height: navigationBar.bounds.height) without it is useless.

It seems that even if the navigationBar looks correct on screen, its height is actually 0. I even added a UITapGestureRecognizer to the navigationBar and it was still not being called. Hope this helps! Tested on Xcode 8.3.3 and Xcode 9 GM, including on iPhone X.

SunburstEnzo
  • 173
  • 11
0

This is related to UIBarButtonItem not clickable on iOS 11 beta 7? which includes my solution to manually set the size of the containing UIView to non-zero.

Quan Vu
  • 1
  • 1