What i want is, I have NSObject MenuView which has tableView in it, when i click one the of cells it should remove the current UIViewController or UIView on another controller. I have used shared instance of my MainPageController in NSObject didSelectItem method to replace the current view on MainPageController with the new one by using view.willRemoveSubviews(myCurrentView) and addSubView(newView) but it does nothing even not a crash or error. is there anyone could help me with that please? I am stuck on it for a long time...
here is the info of how i did it.
inside of NSObject class's didSelectItem method
let view = UIView()
view.backgroundColor = .red
MainPageController.shared.addCustomSubView(View: view)
and here how i defined it in MainPageController
func addCustomSubView(View: UIView) {
view.willRemoveSubview(inOutView)
view.addSubview(View)
View.anchor(top: headerLine.bottomAnchor, leading: view.leadingAnchor, bottom: footerLine.topAnchor, trailing: view.trailingAnchor, padding: .init(), size: CGSize(width: 0, height: 0))
}
inOutView also the view of my another controller, which i added as a subView of current MainPageController
So i want to replace the inOutView with my new View coming from the NSObject class inside didSelectItem
in
MainPageController:and declare
var mainPageController: MainPageControllerin NSObject class and inside ofdidSelectItemAtIndexPaththis code:by doing this I achieved switching between uiviews that is inside of viewController by using NSObject.