objective c - How to determine, in an app with several ViewControllers attached to NavigationControllers, what the currently displayed View is? -
i have ios 8 app, built objective-c, tabbarcontroller, 3 tabs. each tab links navigationcontroller (so there 3 navigationcontrollers), , each navigationcontroller has stack several viewcontrollers in it.
so, @ given time, app's user can on, say, viewcontroller 2 of navigationcontroller 1 (which means tab 1 selected). , hop tab 3 (navigationcontroller 3) , seeing viewcontroller 1, say.
the question is, no matter viewcontroller app user seeing (and therefore, no matter navigationcontroller / tabbar tab in effect), how can determine (i.e., pointer/reference to) viewcontroller being shown?
do need tabbarcontroller, array of navigationcontrollers, arrays of of viewcontrollers, , cycle through each element see top viewcontroller?
or there short-cut way of determining viewcontroller being shown - , thereby parent navigationcontroller , tab/tabbar? so, like, there "global" handle in ios points 1 view active , being displayed @ given time?
thanks much!
your pretty close. tab controller, navigation controller selected tab. uinavigationcontroller, use topviewcontroller property displayed view controller.
uitabbarcontroller *tabcontroller = ... // reference tab controller uinavigationcontroller *navcontroller = (uinavigationcontroller *)tabcontroller.selectedviewcontrpller; uiviewcontroller *viewcontroller = navcontroller.topviewcontroller;
Comments
Post a Comment