我试图将模态视图控制器显示为UIPresentationFormSheet.视图出现了,但我似乎无法调整它的大小.我的XIB具有适当的高度和;宽度,但当我这样称呼它时,它似乎被覆盖了:

composeTweetController = [[ComposeTweet alloc] initWithNibName:@"ComposeTweet" bundle:nil];
composeTweetController.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentModalViewController:composeTweetController animated:TRUE];

有什么 idea 吗?我使用的是iPhone SDK 3.2 beta 4

推荐答案

在呈现模式视图后,可以调整其框架:

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];
}

Objective-c相关问答推荐

如果DISPATCH_SOURCE_SET_EVENT_HANDLER中的SELF需要为弱

为何在Objective-C中,使用self.propName赋值会导致崩溃而使用_ivarName则不会?

在 MacOS 上截屏

单例实例与类方法

Objective-C - 将浮点数转换为字符串的其他方法

如何获取 NSDictionary 中的第一个元素?

如何创建圆形按钮?

Xcode 是否支持区域?

将 CSS 插入 UIWebView / WKWebView 中加载的 HTML

自动属性合成 (@property) 和继承

在 iOS 设备上本地存储图像

如何更改 UICollectionView 中的滚动方向?

arc4random 和 arc4random_uniform 有什么区别?

首次提交应用内购买以供审核

在我滚动之前,数据不会加载到 UITableView 中

为什么 LLDB 不能打印 view.bounds?

如何修复UIPopoverController 已弃用警告?

为什么使用弱指针进行委托?

无法在 iOS7 上将 UITextField 添加到 UIAlertView ...在 iOS 6 中有效

UITableViewCell中的文本居中对齐问题