I have a UIViewController (AbcViewController) with NavigationController. AbcViewController uses UIView (AbcView) as its view. AbcView has a UITableView. I have set this TableView‘s datasource in AbcViewController and delegate in its SuperView i.e. AbcView. How will I push another UIViewController (XyzViewcontroller) into navigationController when I select a row in this table because it gives
“error: request for member ‘navigationController’ in something not a structure or union”
when I do this:
[self.navigationController pushViewController:xyzViewcontroller animated:TRUE];
I also did this:
AbcViewController *parentVC;
[parentVC.navigationController pushViewController:xyzViewcontroller animated:TRUE];
Though it builds successfully, XyzViewcontroller‘s view does not appear. It does not push XyzViewcontroller‘s view onto navigationController.
We can make a delegate on
AbcViewso that we can refer back to the view’s viewController which in this case isAbcViewController. We can set delegate as:Then in
AbcViewController, set the view’s delegate like this:Now in table method using our delegate from within AbcView as:
it will call
- (void)pushOtherViewmethod inAbcViewControllerwhose definition is:But before using this method, it should be mentioned in protocols otherwise it will show