iosobjective-cipadcocoa-touchuikit

How to resize a UIModalPresentationFormSheet?


I am trying to display a modal view controller as a UIPresentationFormSheet. The view appears, but I can't seem to resize it. My XIB has the proper height & width, but it seems to get overridden when I call it like this:

composeTweetController = [[ComposeTweet alloc] initWithNibName:@"ComposeTweet" bundle:nil];
composeTweetController.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentModalViewController:composeTweetController animated:TRUE];

Any thoughts? I am using the iPhone SDK 3.2 beta 4


Solution

  • You are able to adjust the frame of a modal view after presenting it:

    Tested in iOS 5.1 - 7.1

    MyModalViewController *targetController = [[[MyModalViewController alloc] init] autorelease];
    targetController.modalPresentationStyle = UIModalPresentationFormSheet;
    targetController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;  //transition shouldn't matter
    [self presentViewController:targetController animated:YES completion:nil];
    
    if(floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_6_1){
         targetController.view.superview.frame = CGRectInset(targetController.view.superview.frame, 100, 50);
    }else{
         targetController.view.frame = CGRectInset(targetController.view.frame, 100, 50);
         targetController.view.superview.backgroundColor = [UIColor clearColor];
    }