I am new to iOS development and I am making a left menu bar like many applications. I got to a point but now I am stuck. Please help.
I have a class called LeftMenu and it is declared as follows:
class LeftMenu: UIView, UITableViewDelegate, UITableViewDataSource {
The reason is I am using the same LeftMenu in multiple UIViewControllers
There is a tableView which represents the scrollMenu and I am observing the selected row like this:
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
switch self.menuItems[indexPath.row] {
case "Wever":
print(self.menuItems[indexPath.row])
case "Payments":
print(self.menuItems[indexPath.row])
case "Profile":
print(self.menuItems[indexPath.row])
case "Trip History":
print(self.menuItems[indexPath.row])
case "Referral":
print(self.menuItems[indexPath.row])
case "Help":
print(self.menuItems[indexPath.row])
case "Settings":
print(self.menuItems[indexPath.row])
case "About":
print(self.menuItems[indexPath.row])
default:
break
}
}
I use the LeftMenu for bringing up menu in the each of the view controller.
What I would like to do is open the corresponding view controller when a cell in the tableView is selected. Please help.