UIModalPresentationFullScreen无法在iPad横向模式下工作?

时间:2011-06-20 15:00:57

标签: cocoa-touch ipad modalviewcontroller

我在ViewController(A)上添加了ViewvController(B)作为子视图。在ViewController A(SuperView)UIModelPresentationFullScreen中工作正常。但是当我在ViewController B(SubView)中调用UIModelPresentationFull时,它的模型视图以纵向模式显示,并且也未完全查看。如何解决这个问题呢。任何人都可以帮助我。我试过了2天。

这是我在superview和subview中尝试过的......

picFBCapture *fbCapt = [[picFBCapture alloc] init];
//[self.navigationController pushViewController:fbCapt animated:YES];
//fbCapt.modalPresentationStyle = UIModalTransitionStyleFlipHorizontal;
fbCapt.modalTransitionStyle = UIModalPresentationFullScreen;
[self presentModalViewController:fbCapt animated:NO]; 
[fbCapt release]; 

提前致谢..

2 个答案:

答案 0 :(得分:1)

问题在于,如果将视图控制器添加为子视图,则它未连接到视图控制器层次结构,因此某些操作无效。您应该尽可能避免将视图控制器添加为子视图,因为这不是Apple打算使用视图控制器的方式,但有时无法避免。

如果这是无法避免的情况之一,则应在视图控制器B中保存对视图控制器A的引用,然后在视图控制器A(连接到视图控制器)上调用presentModalViewController:层次结构)而不是self(视图控制器B,未连接)。

编辑:在控制器A中,您的代码可能类似于:

[self.view addSubview:controllerB.view];

与此行一起添加:

controllerB.controllerA = self;

我希望你知道如何创建属性,但如果不是,这是一个提示:

@property (nonatomic, assign) UIViewController *controllerA;

其余的你应该能够弄清楚使用谷歌和文档。

答案 1 :(得分:0)

您必须自己处理viewController B的景观视图。由于viewController B已添加为子视图,因此其视图控制器将不会处理其横向方向。 UIModalPresentationFullScreen样式(横向和纵向)仅在显示viewController B时才有效,即不作为子视图而是作为完整视图本身。