Or you can simply put all the logic that you execute when the button is clicked in a separate method and call that method from your button selection method.
@IBAction func someButtonPressed(button: UIButton) { pushViewControllerOne() } @IBAction func someButtonPressed(button: UIButton) { pushViewControllerTwo() } func pushViewControllerOne() { let viewController = ViewControllerOne(nibName: "ViewControllerOne", bundle: nil) pushViewController(viewController) } func pushViewControllerTwo() { let viewController = ViewControllerOne(nibName: "ViewControllerTwo", bundle: nil) pushViewController(viewController) } func pushViewController(viewController: UIViewController) { navigationController?.pushViewController(viewController, animated: true) }
Then, instead of calling the program call of the button, click, just call the pushViewControllerOne() or pushViewControllerTwo() method
Sajjon
source share