i am using MZFormSheetPresentationController to display a dialogue to ask the user enter his password as shown in the figure bellow:
after the user click OK another view controller is presented as shown in the figure below:
but after dismissing the new view controller the old view controller still persist i already made some researches about how to dismiss view controller before presenting new one i found one solution here using delegate but i am still new to iOS and cannot figure out how to apply such answer in my case here my code what i am using:
- (IBAction)okButtonTouchDown:(id)sender {
// UIStoryboard *storyboard = self.storyboard;
// UINavigationController *nav = [storyboard instantiateViewControllerWithIdentifier:@"myprofile"];
// [self presentViewController:nav animated:YES completion:^{
// [self dismissViewControllerAnimated:YES completion:nil]; // here the self point to the new view controller not to the old one //
//[self dismissViewControllerAnimated:YES completion:^{
// UINavigationController *nav = [storyboard instantiateViewControllerWithIdentifier:@"myprofile"];
// [self presentViewController:nav animated:YES completion:^{
//}];
// }];
//}];
__weak EditProfileViewController *aBlockSelf = self;
UIStoryboard *storyboard = self.storyboard;
UINavigationController *nav = [storyboard instantiateViewControllerWithIdentifier:@"myprofile"];
[self presentViewController:nav animated:YES completion:^{
[[aBlockSelf presentingViewController] dismissViewControllerAnimated:YES completion:nil];
}];
}
// i try this solution but the new view controller presented and after some time dismissed //
EVEN if i try to dismissviewcontroller with completion i go into this error Warning: Attempt to present on whose view is not in the window hierarchy!
so is there way to solve this problem not using delegate and protocol method ?