I have a storyboardViewController (UITableViewController) and 1 item of that table is 'USERS' (UIButton) but I need to join it with a .XIB, this .XIB is in the same proyect.
I can not to do a segue between the UIButton with the .XIB. Pls Helpme :D
I have a storyboardViewController (UITableViewController) and 1 item of that table is 'USERS' (UIButton) but I need to join it with a .XIB, this .XIB is in the same proyect.
I can not to do a segue between the UIButton with the .XIB. Pls Helpme :D
Connect the UIButton
with an @IBAction
and add the following code to the action method to present a new UIViewController
that is set up inside a .xib file.
@IBAction func handleButtonAction(_ sender: UIButton) {
let viewControllerInXib = ViewControllerInXib(nibName: "ViewControllerXibName", bundle: nil)
present(viewControllerInXib, animated: true)
}
To navigate via UINavigationController
you should use this method:
@IBAction func handleButtonAction(_ sender: UIButton) {
let viewControllerInXib = ViewControllerInXib(nibName: "ViewControllerXibName", bundle: nil)
if let navigationController = navigationController {
navigationController.pushViewController(viewControllerInXib, animated: true)
} else {
print("Navigation controller unavailable! Use present method.")
}
}