UIModalPresentationFullScreen not working in iPad landscape mode?

醉酒当歌 提交于 2019-12-02 12:29:24

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.

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.

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