Search code examples
iosswiftuinavigationcontroller

Navigation bar showing up but not right bar button


I'm using PageController which shows my current VC. PageController is used to have a Photos app like view for scrolling photos. On my ViewPhotoViewController which is in PageControl it shows the navigation bar on top with back button but when I assigned rightBarButton to it, that rightBarButton is not showing up.

let rightButtonItem = UIBarButtonItem.init(
    title: "Share",
    style: .done,
    target: self,
    action: #selector(rightButtonAction(sender:))
)

self.navigationItem.rightBarButtonItem = rightButtonItem

enter image description here


Solution

  • You need to add rightBarButton on your PageController instead on your ViewPhotoViewController. Navigation bar shown on ViewPhotoViewController is actually of PageController.