I am going to do my best to explain my problem, so thanks in advance.
I usually build applications with many view controllers by having each ViewController represent a different view. Right now, I am creating a large application with many different views. I do not want to have 15+ ViewControllers in my application. I would rather have one ViewController inherit different UIViews.
For example, if on my menu bar I select the "Profile" option. I would then be taken to the selectionController and have the selectionController inherit the UIView named Settings View
For some reason upon calling the function to display the profileView nothing happens. I have implemented a similar feature like this before but not it isn't working.
HomeController
//This function is called upon menu tap
func displayController(menuOption: MenuOption, view: UIView) {
let selectionController = UIViewController()
selectionController.view.frame = UIScreen.main.bounds
selectionController.navigationItem.title = menuOption.name
selectionController.view.backgroundColor = Color.defaultBackgrondColor
selectionController.view.addSubview(view)
navigationController?.navigationBar.tintColor = UIColor.white
navigationController?.pushViewController(selectionController, animated: true)
}
Menu Bar
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
//CARRY OUT ANIMATION FOR MENU BAR...
}) { (completed: Bool) in
let option = self.menuOptions[indexPath.row]
switch option.name {
case "Profile":
//This is where I call my function to display the new view
self.homeController?.displayController(menuOption: option, view: ProfileView(frame: UIScreen.main.bounds))
default:
print("Staying on home page")
}
}
}
self.homeController
isn't nil. If that's not the problem, make surehomeController
is actually in a navigation controller. – rmaddy