i'm using swift4
, this is my design structure first view controller is
SWRevealViewController
has sw_front
segue to UITabBarViewController
, and sw_rear
to UITableViewController
i have back button and menu button in every view controller, I want to use the default action of back button in each view controller baut i didn't know how, is there any way that solve this problem
class SuperViewController: UIViewController {
func goBackNavigationBarItem(){
//Left Button - Navigation bar
let leftButton = UIBarButtonItem(image: UIImage(named: imgName)?.withRenderingMode(.alwaysOriginal), style: .plain, target: self, action: #selector(SuperViewController.btnBackClicked(_:)))
self.navigationItem.leftBarButtonItem = leftButton;
}
func btnBackClicked(_ sender:UIButton!){
// whatever action You want on back button
}
}
make your viewController child of SuperViewController and Call this function goBackNavigationBarItem() in viewDidLoad() of every view controller Like this..
class AnyVC: SuperViewController{
override func viewDidLoad() {
super.viewDidLoad()
goBackNavigationBarItem()
}
}
Hope this help.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.