ios - backBarbuttonitem does nothing? -
i have set navigation programmatically
in view controller set backbutton , change title per documentation. clicking on button in child controller nothing.
what did miss?
> in viewcontroller let backitem = uibarbuttonitem() backitem.title = "" navigationitem.backbarbuttonitem = backitem self.navigationcontroller?.pushviewcontroller(secondviewcontroller, animated: true)
you have add target , action button,
let backitem = uibarbuttonitem() backitem.title = "" backitem.target = self backitem.action = #selector(back) navigationitem.backbarbuttonitem = backitem self.navigationcontroller?.pushviewcontroller(secondviewcontroller, animated: true)
and implement back() function.
func back() { // if view controller presented navigation controller self.navigationcontroller?.popviewcontrolleranimated(true) // if view controller presented modally self.presentingviewcontroller?.dismiss(animated: true, completion: nil) }
Comments
Post a Comment