在ios 7和之前,我正在更新presentViewController.view.superview的边界以自定义呈现的视图控制器的大小,但似乎在ios 8中不再是这种情况.由于没有superview可以在视图控制器上设置(当你尝试在调试器中调用它时返回nil).
有关如何更新显示的视图控制器大小的任何建议吗?这将用于自定义演示文稿转换.
我试图通过减少其宽度和高度在iPad上显示modalView,但问题是它不是中心对齐的.在iOS 6中它过去工作正常,但在iOS 7中它不是中心对齐的.
以下是我的代码:
m_helpQA = [[HelpQAViewController alloc]init];
m_helpQA.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentViewController:m_helpQA animated:YES completion:NULL];
m_helpQA.view.superview.bounds = CGRectMake(0, 0, 350, 250);//Dimensions of ModalView.
Run Code Online (Sandbox Code Playgroud)
目前我正是这样做的

我提出了一个小的"登录" UIViewController作为UIModalPresentationFormSheet自定义边界.在该viewWillLayoutSubviews方法中,我将视图的大小更改为(300,250).这在iOS 5/6/7中有效,但在8中不再有效.
当显示视图并点击a时UITextField,应用程序变得无响应(未冻结,只是没有响应触摸).几乎就像键盘出现但没有出现.委托方法被正确调用.如果我self.view.superview.bounds = CGRectMake(0, 0, 300, 250);从viewWillLayoutSubviews方法中删除键盘,但视图现在是全尺寸UIModalPresentationFormSheet样式.
这只发生在iOS 8中,所以我只能假设键盘呈现的方式以及我屏蔽/调整视图大小的方式存在问题,但我对解决方案感到茫然.
呈现ViewController -
UserLoginViewController *loginVC = [[UserLoginViewController alloc] initWithNibName:@"UserLoginViewController" bundle:nil];
loginVC.modalPresentationStyle = UIModalPresentationFormSheet;
loginVC.delegate = self;
[self presentViewController:loginVC animated:YES completion:nil];
Run Code Online (Sandbox Code Playgroud)
编辑视图边界 -
- (void)viewWillLayoutSubviews {
[super viewWillLayoutSubviews];
self.view.superview.layer.cornerRadius = 10.0;
self.view.superview.layer.masksToBounds = YES;
self.view.superview.bounds = CGRectMake(0, 0, 300, 250);
}
Run Code Online (Sandbox Code Playgroud)