I programmatically created a toolbar that has 2 bar button items: btnPlus
and btnRating
(fixedSpace is just used to set the distance between them). What I want to do is when a user clicks on btnPlus
, the button will direct user to the FifthViewController
and when the user taps on btnRating
it will direct user to the SixthViewController
. I have the below code but how can I know which button the user has clicked in this case and based on that direct it to the relevant viewController
? I'd appreciate any help! Thank you very much in advance!
navigationItem.rightBarButtonItems = [btnPlus, fixedSpace, btnRating]
@objc func OnbtnPlusTouched()
{
guard let uivc = storyboard!.instantiateViewController(withIdentifier: "FifthViewController") as? FifthViewController else {
return
}
navigationController!.pushViewController(uivc, animated: true)