在 IOS 6 之前,我使用以下代码来呈现具有自定义大小的模态视图:
- (void) showModalViewWithController:(GUIViewController*) _viewController {
[UIView beginAnimations:@"" context:nil];
[self presentModalViewController:_viewController animated:YES];
_viewController.view.superview.autoresizingMask = UIViewAutoresizingFlexibleHeight;
_viewController.view.superview.frame = CGRectMake(
_viewController.view.superview.frame.origin.x,
_viewController.view.superview.frame.origin.y,
700.0f,
self.view.frame.size.height - 80.f);
_viewController.view.superview.center = self.view.center;
[UIView commitAnimations];
}
现在我必须更改功能
- (void)presentModalViewController: (UIViewController *)viewControllerToPresent animated:(BOOL)flag
至
- (void)presentViewController: (UIViewController *)viewControllerToPresent animated: (BOOL)flag completion: (void (^)(void))completion
不幸的是,在这样的更改之后调整大小效果不佳:
- (void) showModalViewWithController:(GUIViewController*) _viewController {
[self presentViewController:_viewController animated:YES completion:^(){
[UIView beginAnimations:@"" context:nil];
_viewController.view.superview.autoresizingMask = UIViewAutoresizingFlexibleHeight;
_viewController.view.superview.frame = CGRectMake(
_viewController.view.superview.frame.origin.x,
_viewController.view.superview.frame.origin.y,
700.0f,
self.view.frame.size.height - 80.f);
_viewController.view.superview.center = self.view.center;
[UIView commitAnimations];
}];
}
因为模态视图在它的框架操作之前呈现并且它在调用完成块之后跳转。
如何处理?
提前致谢,
米哈乌