Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Navigation Left bar button item with back button [duplicate]

I want to add left bar button item in navaigationBar. I have back button sign (do not have any text) in left side and when I add leftBarButtonItem then I can not see the back button.

How can I solve this problem.

This is my code:

let phonePhoto = UIButton()
phonePhoto.setImage(UIImage(named: "navigationPhone"), for: UIControlState())
phonePhoto.frame = CGRect(x: 0, y: 0, width: 40, height: 40)
phonePhoto.addTarget(self, action: #selector(userEdit), for: .touchUpInside)

let userPhone = UIBarButtonItem()
userPhone.customView = phonePhoto

self.navigationItem.leftBarButtonItem = userPhone
like image 248
John Avatar asked Oct 22 '16 12:10

John


1 Answers

The presence of custom left bar button items causes the back button to be removed in favor of the custom items. Set navigationItem property leftItemsSupplementBackButton to true will display back button also with your custom left bar item.

self.navigationItem.leftItemsSupplementBackButton = true

Check Apple Documentation on leftItemsSupplementBackButton for more details.

like image 177
Nirav D Avatar answered Sep 18 '22 05:09

Nirav D