【问题标题】:How can I use UIModalPresentationFormSheet with NavigationController in iPad?如何在 iPad 中将 UIModalPresentationFormSheet 与 NavigationController 一起使用?
【发布时间】:2011-04-24 12:16:23
【问题描述】:
我想在我的应用程序中使用 UIModalPresentationFormSheet。但我正在使用导航控制器。因此,当我编写以下代码时,它没有响应我。我该怎么办?
[self.navigationController pushViewController:controller animated:YES];
【问题讨论】:
标签:
iphone
objective-c
cocoa-touch
ipad
ios4
【解决方案1】:
试试这样的:
// assume controller is UIViewController.
controller.modalPresentationStyle = UIModalPresentationFormSheet;
然后
[self.navigationController presentModalViewController:controller animated:YES];
【解决方案2】:
检查以下示例工作代码。
MyModalViewController *targetController = [[[MyModalViewController alloc] init] autorelease];
targetController.modalPresentationStyle = UIModalPresentationFormSheet;
targetController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal; //transition shouldn't matter
[self presentModalViewController:targetController animated:YES];
targetController.view.superview.frame = CGRectMake(0, 0, 200, 200);//it's important to do this after
presentModalViewController targetController.view.superview.center = self.view.center;
取自 -->
How to resize a UIModalPresentationFormSheet?