ios - How can I check if current ViewController is the one I am about to push? -
is there way conditionally check if current view view going push? example, on event want programmatically force secondviewcontroller this:
if(someevent == true) { if(currentviewcontroller != secondviewcontroller) { // load secondviewcontroller navigationcontroller?.pushviewcontroller(secondviewcontroller uiviewcontroller, animated: true) } else { // don't load secondviewcontroller } } so far continually reload secondviewcontroller , stacks on hierarchy in navigationcontroller. how can compare current view see if loaded?
many share knowledge.
note swift update keyword has changed.
check if visibleviewcontroller of navigationcontroller instance of secondviewcontroller or not.use ismemberofclass check instance
if(someevent == true) { if self.navigationcontroller!.visibleviewcontroller.ismemberofclass(secondviewcontroller) { // don't load secondviewcontroller } else { // load secondviewcontroller navigationcontroller?.pushviewcontroller(secondviewcontroller uiviewcontroller, animated: true) } } ios swift
No comments:
Post a Comment