本文介绍了如何调整UIModalPresentationFormSheet的大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图显示一个模态视图控制器作为UIPresentationFormSheet。视图出现,但我似乎无法调整它的大小。我的XIB有适当的高度&宽度,但是当我这样调用它似乎被覆盖:
composeTweetController = [[ComposeTweet alloc] initWithNibName:@ ComposeTweetbundle:nil];
composeTweetController.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentModalViewController:composeTweetController animated:TRUE];
有任何想法吗?我使用的是iPhone SDK 3.2 beta 4
解决方案
显示模式视图后,你可以调整框架: / p>
在iOS 5.1 - 7.1版测试
MyModalViewController * targetController = [[[MyModalViewController alloc] init] autorelease];
targetController.modalPresentationStyle = UIModalPresentationFormSheet;
targetController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal; // transition should not matter
[self presentViewController:targetController animated:YES completion:nil];
if(floor(NSFoundationVersionNumber)< = NSFoundationVersionNumber_iOS_6_1){
targetController.view.superview.frame = CGRectInset(targetController.view.superview.frame,100,50);
} else {
targetController.view.frame = CGRectInset(targetController.view.frame,100,50);
targetController.view.superview.backgroundColor = [UIColor clearColor];
}
I am trying to display a modal view controller as a UIPresentationFormSheet. The view appears, but I can't seem to resize it. My XIB has the proper height & width, but it seems to get overridden when I call it like this:
composeTweetController = [[ComposeTweet alloc] initWithNibName:@"ComposeTweet" bundle:nil];
composeTweetController.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentModalViewController:composeTweetController animated:TRUE];
Any thoughts? I am using the iPhone SDK 3.2 beta 4
解决方案
You are able to adjust the frame of a modal view after presenting it:
Tested in iOS 5.1 - 7.1
MyModalViewController *targetController = [[[MyModalViewController alloc] init] autorelease];
targetController.modalPresentationStyle = UIModalPresentationFormSheet;
targetController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal; //transition shouldn't matter
[self presentViewController:targetController animated:YES completion:nil];
if(floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_6_1){
targetController.view.superview.frame = CGRectInset(targetController.view.superview.frame, 100, 50);
}else{
targetController.view.frame = CGRectInset(targetController.view.frame, 100, 50);
targetController.view.superview.backgroundColor = [UIColor clearColor];
}
这篇关于如何调整UIModalPresentationFormSheet的大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!