title: Change Modal View Size From Within Modal View Controller
body: <p>One of my view controllers loads another with presentation style of <code>UIModalPresentationFormSheet</code>:</p>
  
  <pre><code>- (void)loadNotesForm {
  if ([helper isOrderReadyForSubmission:self.coreDataOrder]) {
      CIFinalCustomerInfoViewController *ci = [[CIFinalCustomerInfoViewController alloc] init];
      ci.order = self.coreDataOrder;
      ci.modalPresentationStyle = UIModalPresentationFormSheet;
      ci.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
      ci.delegate = self;
      [self presentViewController:ci animated:YES completion:nil];
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Inside this modal (CIFinalCustomerInfoViewController) I construct the view programmatically:</p>
  
  <pre><code>    - (void)loadView
  {
      UIView *view = [[UIView alloc] initWithFrame:[UIScreen mainScreen].applicationFrame];
      [view setBackgroundColor:[UIColor blackColor]];
      self.view = view;
      CGFloat currentY = 8.0;
      CGFloat verticalMargin = 8.0;
      CGFloat horizontalMargin = 12.0;
      UIFont *labelFont =  [UIFont fontWithName:@"Futura-MediumItalic" size:27.0f];
      UILabel *authorizedByLabel = [[UILabel alloc] initWithFrame:CGRectMake(62.0, currentY, 300.0, 35.0)];
      authorizedByLabel.font = labelFont;
      authorizedByLabel.textColor = [UIColor whiteColor];
      authorizedByLabel.text = @"Authorized By";
      [self.view addSubview:authorizedByLabel];
      self.authorizedByTextField = [[UITextField alloc] initWithFrame:CGRectMake(62.0, CGRectGetMaxY(authorizedByLabel.frame)+ verticalMargin, 419.0, 44.0)];
      self.authorizedByTextField.backgroundColor = [UIColor whiteColor];
      [self.view addSubview:self.authorizedByTextField];
      UILabel *notesLabel = [[UILabel alloc] initWithFrame:CGRectMake(62.0, CGRectGetMaxY(self.authorizedByTextField.frame) + verticalMargin, 300.0, 35.0)];
      notesLabel.font = labelFont;
      notesLabel.textColor = [UIColor whiteColor];
      notesLabel.text = @"Notes";
      [self.view addSubview:notesLabel];
      self.notesTextView = [[UITextView  alloc] initWithFrame:CGRectMake(62.0, CGRectGetMaxY(notesLabel.frame) + verticalMargin, 419.0, 100.0)];
      [self.view addSubview:self.notesTextView];
      UILabel *shipNotesLabel = [[UILabel alloc] initWithFrame:CGRectMake(62.0, CGRectGetMaxY(self.notesTextView.frame) + verticalMargin, 300.0, 35.0)];
      shipNotesLabel.font = labelFont;
      shipNotesLabel.textColor = [UIColor whiteColor];
      shipNotesLabel.text = @"Ship Notes";
      [self.view addSubview:shipNotesLabel];
      self.shipNotesTextView = [[UITextView  alloc] initWithFrame:CGRectMake(62.0, CGRectGetMaxY(shipNotesLabel.frame) + verticalMargin, 419.0, 80.0)];
      [self.view addSubview:self.shipNotesTextView];
      currentY = CGRectGetMaxY(self.shipNotesTextView.frame);
      if (self.contactBeforeShippingConfig) {
          UILabel *contactLabel = [[UILabel alloc] initWithFrame:CGRectMake(62.0, currentY, 300.0, 35.0)];
          contactLabel.font = labelFont;
          contactLabel.textColor = [UIColor whiteColor];
          contactLabel.text = @"Contact Before Shipping?";
          [self.view addSubview:contactLabel];
          self.contactBeforeShippingCB.frame = CGRectMake(62 + CGRectGetMaxX(contactLabel.frame) + horizontalMargin, contactLabel.frame.origin.y, 150, 35);
          [self.view addSubview:self.contactBeforeShippingCB];
          currentY = CGRectGetMaxY(self.contactBeforeShippingCB.frame);
      }
      if(self.cancelConfig){
          UILabel *cancelLabel = [[UILabel alloc] initWithFrame:CGRectMake(62.0, currentY, 300.0, 35.0)];
          cancelLabel.font = labelFont;
          cancelLabel.textColor = [UIColor whiteColor];
          cancelLabel.text = @"Cancel if not shipped within following days?";
          [self.view addSubview:cancelLabel];
          self.cancelBeforeDaysPicker.frame = CGRectMake(62, CGRectGetMaxY(cancelLabel.frame), 400, 100);
          [self.view addSubview:self.cancelBeforeDaysPicker];
          currentY = CGRectGetMaxY(self.cancelBeforeDaysPicker.frame);
      }
      UIButton *cancelButton = [UIButton buttonWithType:UIButtonTypeCustom];
      [cancelButton addTarget:self action:@selector(back:) forControlEvents:UIControlEventTouchDown];
      [cancelButton setBackgroundImage:[UIImage imageNamed:@"cart-cancelout.png"] forState:UIControlStateNormal];
      [cancelButton setBackgroundImage:[UIImage imageNamed:@"cart-cancelin.png"] forState:UIControlStateHighlighted];
      cancelButton.frame = CGRectMake(62.0, currentY+verticalMargin, 162.0, 56.0);
      UIButton *submitButton = [UIButton buttonWithType:UIButtonTypeCustom];
      [submitButton addTarget:self action:@selector(submit:) forControlEvents:UIControlEventTouchDown];
      [submitButton setBackgroundImage:[UIImage imageNamed:@"submitorderout.png"] forState:UIControlStateNormal];
      [submitButton setBackgroundImage:[UIImage imageNamed:@"submitorderin.png"] forState:UIControlStateSelected];
      submitButton.frame = CGRectMake(cancelButton.frame.origin.x + cancelButton.frame.size.width + horizontalMargin , cancelButton.frame.origin.y, 260.0, 56.0);
      currentY = CGRectGetMaxY(submitButton.frame);
      [self.view addSubview:cancelButton];
      [self.view addSubview:submitButton];
  }
  </code></pre>
  
  <p>I want the modal's frame height to adjust so as to just fit the content added in loadView method. If I set frame size from within load view, that doesn't work. Other posts on SO suggest changing the size of the modal from the controller that presented it and that works. But the controller that presented it will not know what height will just cover the content that was loaded by the modal's <code>loadView</code> method.</p>
  
  <p>Is there no way to make the modal's height fit its content from within the modal or from its parent?</p>