0

In my AppDelegate.swift file I have this two lines:

let barButtonItemMenu = UIBarButtonItem.appearance()   
     barButtonItemMenu.setTitleTextAttributes([NSAttributedStringKey.foregroundColor: UIColor.clear], for: .normal)

that allows me to remove the back text in my all navigation controllers. All is good but when I open the photo gallery with UIImagePickerController the Cancel button does not appear, but when I delete that two lines the Cancel button appears and my back text appears.

My question is how can I show the Cancel button in my photo gallery? and how can I remove the back text in my all navigation controllers?

Faysal Ahmed
  • 7,501
  • 5
  • 28
  • 50
Dimoreno
  • 227
  • 3
  • 15

2 Answers2

2

Basically you are clearing text of navigation controller button

You can try doing one thing instead of clearing text of back button using

let barButtonItemMenu = UIBarButtonItem.appearance()   
     barButtonItemMenu.setTitleTextAttributes([NSAttributedStringKey.foregroundColor: UIColor.clear], for: .normal)

Make use of

self.navigationItem.setHidesBackButton(true, animated: false)

This will not clear your text as you doing but will hide the button in navigation stack

You can just use this simple line in WillAppear to make that button hide

ScreenShot 1 - After navigating to VC1 from other Vc which do not show Back Button as Required - Expected Output

enter image description here

ScreenShot 2 - When Clicked on Button at centre of VC1 library is presented using imagePicker which having cancel button as shown - Expected Output

enter image description here

Have A look at demo project - https://drive.google.com/open?id=1exKMgZSQZ8zT64yJOh-MX5O-uAIPdrj6

iOS Geek
  • 4,825
  • 1
  • 9
  • 30
0

This is not correct way to remove back button text. You are actually changing the color of button to clear which makes it invisible but button remains there and it is still interact able. Correct way to remove back button text is remove back button text

And when you’ll do this, your image picker controller will also have cancel button

Umair Aamir
  • 1,624
  • 16
  • 26