UIViewController - UIModalPresentationCurrentContext不旋转presentingViewController

8

我曾经使用 UIModalPresentationCurrentContext 的模态展示方式,从另一个 UIViewController 中展示 UIViewController。但这样会导致无法旋转呈现视图控制器(即呈现新的 UIViewController 的那个 UIViewController)。

self.modalPresentationStyle = UIModalPresentationCurrentContext;
NewViewController *newViewController = [[NewViewController alloc] initWithNibName:@"NewViewController" Bundle: nil];
[self presentViewController:newViewController animated:YES completion:nil];

当我旋转设备时,它会旋转`newViewController`和`statusbar`但不会旋转`presentingViewController`(即`self`)。
PS: 这里的`presentingViewController`是`self`。

presentingViewController是否是其他控制器的子控制器?也许您忘记将其添加为子控制器,因此它无法接收到任何事件。 - Maciej Oczko
不,它是rootViewController。 - Rafeek
在其他的演示样式中它可以正常工作,但在“UIModalPresentationCurrentContext”中却不行。 - Rafeek
请查看此答案:https://dev59.com/aHTYa4cB1Zd3GeqPzdc7#17839785 - Krrish
我也遇到了同样的问题...你找到答案了吗? - karan
不要使用 UIModalPresentationCurrentContext。我将其更改为 UIModelPresentationFormSheet 并更改其父视图大小,这解决了我的问题。 - Rafeek
1个回答

0

使用 UIModalPresentationFormSheet 替代 UIModalPresentationCurrentContext

试试这个

self.modalPresentationStyle = UIModelPresentationFormSheet; NewViewController *newViewController = [[NewViewController alloc] initWithNibName:@"NewViewController" Bundle: nil]; [self presentViewController:newViewController animated:YES completion:nil];


UIModalPresentationFormSheet 在 iPhone 上不可用。 - Rafeek

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接