Monday 28 January 2013

Dismiss modalView Controller from Navigation Controller on appDelegate window

Assume:
If you want to check the controller if it exists, then remove it from the stack.
There are 2 ways to check the controller.
1) using NSStringFromClass.
2) give tag to your controller.(self.view.tag = INTEGER_VALUE)

First Approach:
NSString *modalClassName = NSStringFromClass([YOUR_CONTROLLER class]);    
if (modalClassName) {
NSLog(@"Remove it From Stack");
[appDelegate.window.rootViewController dismissModalViewControllerAnimated:NO];
}

Second Approach:
if([appDelegate.window viewWithTag:YOUR_INTEGER_VALUE]){
NSLog(@"Remove it From Stack");
[appDelegate.window.rootViewController dismissModalViewControllerAnimated:NO];
}

No comments:

Post a Comment