UIModalPresentationFullScreen not working in iPad landscape mode?

夙愿已清 提交于 2019-12-31 07:08:31

问题


I have added a ViewvController(B) as subview on ViewController(A). In ViewController A(SuperView) UIModelPresentationFullScreen working fine. But when am calling UIModelPresentationFull in ViewController B(SubView) it modelview showing in Portrait mode and that is also not fully viewed. How to solve this problem. Can any one help me please. I have tried 2 days.

This is what I tried in both the superview and 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]; 

Thanks in advance..


回答1:


The problem is that if you add a view controller as a subview it's not connected to the view controller hierarchy and thus certain things doesn't work. You should avoid adding view controllers as subviews whenever possible, since this is not how Apple intend view controllers to be used, but sometimes it can't be avoided.

If this is one of those cases when it can't be avoided you should save a reference to view controller A in view controller B and then call presentModalViewController: on view controller A (that is connected to the view controller hierarchy) instead of self (view controller B, that isn't connected).

EDIT: In controller A you probably have code looking something like:

[self.view addSubview:controllerB.view];

In conjunction to this line add:

controllerB.controllerA = self;

I hope you know how to create properties, but if not here's a hint:

@property (nonatomic, assign) UIViewController *controllerA;

The rest you should be able to figure out using Google and the documentation.




回答2:


You will have to handle viewController B's view in landscape by yourself. Since viewController B has been added as a subview, its view controller will not be handling its landscape orientation. The UIModalPresentationFullScreen style (landscape and portrait) will work only if viewController B is shown, ie not as subview but as a full view itself.



来源:https://stackoverflow.com/questions/6413263/uimodalpresentationfullscreen-not-working-in-ipad-landscape-mode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!