1

PresentedViewController present from popoverview, this is the code I'm using

SearchPropertyVC *SearchPropertyVC *centerViewController = (SearchPropertyVC *)[board instantiateViewControllerWithIdentifier:@"vcSearchPropertyID"];
UINavigationController *ConDetVC = [[UINavigationController alloc] initWithRootViewController:centerViewController];
ConDetVC.modalPresentationStyle = UIModalPresentationPageSheet;
ConDetVC.modalPresentationStyle = UIModalPresentationFormSheet;
ConDetVC.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;

[self presentViewController:ConDetVC animated:YES completion:nil];
ConDetVC.view.superview.bounds = CGRectMake(0, 0, 700, 670);

controller open fine, when I was try to close the controller I'm getting this Warning

"Warning: Attempt to dismiss from view controller while a presentation or dismiss is in progress!"

after that if I click any button the app will crashed.

this the code I'm using to dismiss the view

[self dismissViewControllerAnimated:YES completion:nil];

[self dismissViewControllerAnimated:YES completion:^{
             [(UINavigationController *)self.presentingViewController popToRootViewControllerAnimated:YES];
         }];

if (![self.presentedViewController isBeingDismissed])
            [self dismissViewControllerAnimated:YES completion:nil];

when I try to dismiss the popover view itself getting the same warning

Mohit
  • 3,708
  • 2
  • 27
  • 30
Rajesh
  • 359
  • 3
  • 14

2 Answers2

0

At very first correct below line.

 SearchPropertyVC *SearchPropertyVC *centerViewController = (SearchPropertyVC *)[board instantiateViewControllerWithIdentifier:@"vcSearchPropertyID"];

 SearchPropertyVC *searchPropertyVC = (SearchPropertyVC *)[board instantiateViewControllerWithIdentifier:@"vcSearchPropertyID"];

choose any one presentation style,

 ConDetVC.modalPresentationStyle = UIModalPresentationPageSheet;
 ConDetVC.modalPresentationStyle = UIModalPresentationFormSheet;

either page sheet or form sheet.

And while you try to present, use object of view controller you want to present.

 [self presentViewController:ConDetVC animated:YES completion:nil]; 

And when it being dismissed, just write,

 [self dismissViewControllerAnimated:YES completion:^{
         // write you code here
     }];
VRAwesome
  • 4,721
  • 5
  • 27
  • 52
  • [ConDetVC presentViewController:ConDetVC animated:YES completion:nil]; this will get error... Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Application tried to present modal view controller on itself. Presenting controller is .' – Rajesh Aug 01 '14 at 05:52
  • Actually this is the process I want to do -- From viewcontroll -> barbutton click -> popoverview (button click here) -> (need to close popupview) open a model presentviewcontroller (Button click) -> (close presentviewcontroller) opne a new presentviewcontroller. and if I click out side the presentviewcontroller need to close the presentviewcontroller. – Rajesh Aug 01 '14 at 05:54
  • @Rajesh, I am sorry for my mistake. Please see edited answer. – VRAwesome Aug 01 '14 at 06:07
  • I fix everything, now only one problem I have, need to close presentviewcontroller when we click outside the window... – Rajesh Aug 01 '14 at 06:28
  • You can dismiss presented view controller on touches event after finding presented view controller – VRAwesome Aug 01 '14 at 06:55
  • I follow this http://stackoverflow.com/questions/2623417/iphone-sdk-dismissing-modal-viewcontrollers-on-ipad-by-clicking-outside-of-it its working but inside the controller I have another view it have UITapGestureRecognizer that will not work. – Rajesh Aug 01 '14 at 07:12
0

This will help you :

 [self.presentedViewController dismissViewControllerAnimated: YES completion:^(void) {
             [self presentViewController:myController animated:YES completion:nil];
    }];