If you were not using a UINavigationController
You could put something like this in the view controller that calls the modal view:
-(void)dismissModalViewControllerAnimated:(BOOL)animated{
if (_someFlagForBeingProperlyLoggedIn) [super dismissModalViewControllerAnimated:animated];
}
When you tap on the page curl the presenting/parent view controller is sent dismissModalViewControllerAnimated:
.
Since you are using a navigation controller your options are limited. This is because UINavigationController
is a subclass of UIViewController
, and a self centered one at that. When you click the page curl it's dismissModalViewControllerAnimated: is being called.
You still have the option of subclassing UINavigationController
and implementing the above method, but that will get messy in a hurry.
Having the UIAlertView "direct back" to the modal login view IS very easy. Have that main view conform to the UIAlertViewDelegate
protocol. When you display the alert set that instance as the delegate, and in that class implement the method:
-(void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex{
// Enclose in if (buttonIndex == #) for selective calling
UINavigationController* nav = (UINavigationController*)[[UIStoryboard storyboardWithName:@"MainStoryboard_iPhone" bundle:nil] instantiateViewControllerWithIdentifier:@"Preferences"];
[nav setModalTransitionStyle:UIModalTransitionStylePartialCurl];
[self.navigationController presentModalViewController:nav animated:YES];
}
Then when the alert view is dismissed it will show the 'login' view.