我只有一个问题与iOS 8中的工作表视图控制器相关。在iOS 7中,我能够使用下面函数中的最后一行代码更改视图控制器的高度:
SendRemainingEvaluationsViewController *sendRemainingEvaluationViewController = [[[SendRemainingEvaluationsViewController alloc] initWithNibName:@"SendRemainingEvaluationsViewController" bundle:nil]autorelease];
UINavigationController *navigationController = [[[UINavigationController alloc] initWithRootViewController:sendRemainingEvaluationViewController] autorelease];
navigationController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
navigationController.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentViewController:navigationController animated:YES completion:nil];
//To Change the default size of the viewController which is presented in UIModalPresentationFormSheet presentation style
navigationController.view.superview.frame = CGRectMake(navigationController.view.superview.frame.origin.x, navigationController.view.superview.frame.origin.y, navigationController.view.superview.frame.size.width, 230);
但这不适用于iOS 8,不知道为什么?有谁知道这是什么问题?任何想法将不胜感激。
提前致谢。
答案 0 :(得分:0)
检查后,我可以找出问题所在。初始化视图导航控制器后,其superview为nil,并且在呈现后无法立即访问它。作为解决方法,您可以在您尝试呈现的视图控制器的viewwillAppear中更改其超级视图的框架,如下所示:
- (void) viewWillAppear:(BOOL)animated
{
self.parentViewController.view.superview.frame = CGRectMake(self.parentViewController.view.superview.frame.origin.x, self.parentViewController.view.superview.frame.origin.y, self.parentViewController.view.superview.frame.size.width, 230);
}
这应该有用。