I am facing a problem in ios6 regarding dismissal of modalViewController
Here is code snippet I am sharing:
UIViewController *controller=appdelegate.navigationController.topViewController;
if(kDeviceVersion>=5.0){
if(controller.parentViewController){
if(controller.parentViewController.parentViewController){
[controller.parentViewController.parentViewController dismissViewControllerAnimated:NO completion:nil];
}
[controller.parentViewController dismissViewControllerAnimated:NO completion:nil];
}
}
else{
if(controller.parentViewController){
if(controller.parentViewController.parentViewController){
[controller.parentViewController.parentViewController dismissModalViewControllerAnimated:NO];
}
[controller.parentViewController dismissModalViewControllerAnimated:NO];
}
}
This code is working fine on ios4.0 to ios 5.1.1. But failed to work on ios6. Those modal view controller that I want to dismiss is not getting dismissed. Instead it showing this error.
attempt to dismiss modal view controller whose view does not currently appear. self = UINavigationController: 0xa947440 modalViewController = UINavigationController: 0x8c36170
But when I tried to present that view controller using presentModalViewController then it shows
Warning: Attempt to present on UINavigationController: 0xa947440 which is already presenting UINavigationController: 0x8c36170
Please suggest me what to do and how to fix this issue for ios6.