Unable to pushViewController for subview

后端 未结 6 1819
北荒
北荒 2021-01-03 08:12

I have a UINavigationController and I have seperate UIViews that I switch between using a UISegmentControl. On switching the views, I add the view as a subview to my navigat

6条回答
  •  囚心锁ツ
    2021-01-03 09:02

    One possibility, if you are not averse to singletons, is to make your product's UINavigationController object be a singleton, accessible from (for example) your application delegate.

    You would invoke it thus:

    [[((MyApplicationDelegate*)[UIApplication delegate]) navController] 
                    pushViewController: viewControllerToPush animated: YES];
    

    where within MyApplicationDelegate, navController returns the singleton object.

提交回复
热议问题