3

I want to use UIModalPresentationFormSheet in my app. But i'm using navigation controller. So when i writes following code it is not responding me. What should i do ?

    [self.navigationController pushViewController:controller animated:YES];
Ahmad Kayyali
  • 8,233
  • 13
  • 49
  • 83
Devang
  • 11,258
  • 13
  • 62
  • 100

2 Answers2

6

Try something like this:

 // assume controller is UIViewController.
 controller.modalPresentationStyle = UIModalPresentationFormSheet;

Then

[self.navigationController presentModalViewController:controller animated:YES];
Ahmad Kayyali
  • 8,233
  • 13
  • 49
  • 83
3

Check with the below sample working code.

MyModalViewController *targetController = [[[MyModalViewController alloc] init] autorelease]; 

targetController.modalPresentationStyle = UIModalPresentationFormSheet;
targetController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal; //transition shouldn't matter 
[self presentModalViewController:targetController animated:YES];

targetController.view.superview.frame = CGRectMake(0, 0, 200, 200);//it's important to do this after 

presentModalViewController targetController.view.superview.center = self.view.center;

Taken from -->

How to resize a UIModalPresentationFormSheet?

Community
  • 1
  • 1
Jhaliya - Praveen Sharma
  • 31,697
  • 9
  • 72
  • 76
  • 22
    You might want to indicate that this was copied from bdrobert's answer here: http://stackoverflow.com/questions/2457947/how-to-resize-a-uipresentationformsheet/4271364#4271364 – Brad Larson May 17 '11 at 18:12