5

I am facing an issue, When i run my app on iPhone SE simulator it shows back button on nav bar like this.

enter image description here

But when i run the same app on iPhone X, iPhone 8 and iPhone 8 plus iOS 11 and XCode 9 there is no back button on nav bar and its for all ViewControllers not for specific viewController. Here is the example

enter image description here

Can anyone tell why is this happening.

Waris Shams
  • 1,606
  • 1
  • 15
  • 27

2 Answers2

1

I had the issue where the back button was only a little bit. In the debugging console it was showing a few broken constraints in the navigation bar.

I found this line in the app delegate to be the issue.

 UIBarButtonItem.appearance().setBackButtonTitlePositionAdjustment( // Remove the text "Back" from the back button so only the back arrow is visible
        UIOffset(horizontal: -100, vertical:-100),
        for: UIBarMetrics.default
    )

try and find any appearance api calls in your code and see if you might be modifying the bar button offsets.

Daniel Hakimi
  • 1,153
  • 9
  • 16
0

After some effort i came to know that i am setting the view's leading space before setting as NavBarTitleView

navView.viewLeadingConstraint.constant = (UIDevice().isIPhone5 || UIDevice().isIPhone4) ? -15:-40

due to above code my back button hides so i removed above line of code and add following method in NavView which resolve my problem.

override var intrinsicContentSize: CGSize {
    return UILayoutFittingExpandedSize
}
Waris Shams
  • 1,606
  • 1
  • 15
  • 27