UIModalPresentationFormSheet调整大小视图

tos*_*osi 43 modal-dialog presentation ipad uimodalpresentationformsh

我想知道在使用时,我如何调整视图大小UIModalPresentationFormSheetmodalPresentationStyle,它看起来像它有一个固定的大小,所以我在想,如果有任何人都设法操纵从大小角度弹出视图.

所以有UIModalPresentationFormSheet一个固定的视图大小或完整的视图,我在介于两者之间.

tos*_*osi 71

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

targetController.modalPresentationStyle = UIModalPresentationFormSheet;

targetController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;

[self presentModalViewController:targetController animated:YES];

// it is important to do this after presentModalViewController:animated:
targetController.view.superview.bounds = CGRectMake(0, 0, 200, 200);
Run Code Online (Sandbox Code Playgroud)

  • 这不是一个好的解决方案,因为它为navigationItem标题添加了某种模糊.这个更好:targetController.view.superview.bounds = CGRectMake(0,0,200,200); 它仍然是中心,不需要... superview.center. (48认同)
  • iOS 8:这在iOS 8中停止工作,并且之前的答案的组合似乎不起作用.对我来说,解决方案是删除所有涉及superview的行,并在"presentModalViewController"行之前添加以下行.[code] targetController.preferredContentSize = CGSizeMake(200,200); [/ code] (11认同)