Search code examples
ios5storyboardmodalviewcontroller

How can I change size when showing a modal view controller using storyboard?


Using storyboard, I create a transition to another view controller using modal style and form sheet presentation. But always has the same size.

How can I change this view controller size using storyboard? I found some code that almost work, but I never get mu modal view controller centered. How to resize a UIModalPresentationFormSheet? Note that I use Storyboard and that code is not for storyboard.

Do you have any idea or suggestion?

By the way, it seems prepareForSegue os called BEFORE viewDidLoad, is this normal?

Thanks a lot for replies.


Solution

  • Although it's a little late.

    I've implemented it before.. I've managed to get UIPresentationFormSheet centered. Here's my code..

    [detailView setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal];
    [detailView setModalPresentationStyle:UIModalPresentationFormSheet];    
    [self presentModalViewController:detailView animated:YES];
    detailView.view.superview.autoresizingMask = UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin;
    float heightOfFrame = 200.0f;
    float widthOfFrame= 400.0f;
    detailView.view.superview.frame = CGRectMake(
        self.view.superview.center.x - (widthOfFrame/2),                                         
        self.view.superview.center.y - (heightOfFrame/2),
        widthOfFrame,
        heightOfFrame
    ); 
    

    Hope I've helped you in some ways.

    Regards, Steve