如何通知父视图控制器有关模式视图控制器中更改的屏幕方向?

发布于 2024-12-10 00:41:47 字数 278 浏览 0 评论 0原文

我在纵向模式下在 UISplitViewController 上方呈现一个模式视图控制器。现在,我将 iPad 旋转到横向模式并关闭模态视图控制器。

UISplitViewController 似乎没有收到有关方向更改的通知: 分割视图控制器的第一个视图被隐藏,第二个视图不占据整个屏幕尺寸。

如果我再次来回旋转,分割视图控制器将再次正常显示。

此外,该问题仅出现在 iOS Simulator 5.0(或运行 iOS5 的设备)上,而不会出现在 4.3 上。

有什么想法吗?

I am presenting a modal view controller above a UISplitViewController while being in Portrait mode. Now I rotate the iPad to the Landscape mode and dismiss the modal view controller.

It seems that UISplitViewController didn't receive the notification about the changed orientation:
The 1st view of the split view controller is hidden, and the view of the 2nd is not occupying the whole screen size.

If I rotate again back and forth, the split view controller is displayed normally again.

Moreover, the problem occurs only with the iOS Simulator 5.0 (or the device running iOS5) but not with the 4.3.

Any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

一向肩并 2024-12-17 00:41:48

我也有同样的问题。

在我的项目中 splitViewController 添加为窗口上的子视图。并且正常接收轮换消息。但是当我尝试将我的“模态”viewController 添加为窗口上的子视图时,它不会收到旋转消息。看起来旋转消息只接收索引 0 处的子视图。所以我用这种方式解决了它:

Showing "modal" viewController

[appDelegate.window insertSubview:myModalViewController.view atIndex:0];
[appDelegate.splitViewController.view removeFromSuperview];

Hiding "modal" viewController

[appDelegate.window insertSubview:appDelegate.splitViewController.view atIndex:0];
[myModalViewController.view removeFromSuperview];

但是这个解决方案有一个缺陷: modalViewController 在调用 "< 后不会立即加载其视图code>[appDelegate.window insertSubview:myModalViewController.view atIndex:0]”方法。为了修复这个缺陷,我只是暂时将其呈现为模态:

显示“模态”viewController:

// present and dismiss methods are called to cause viewDidLoad in modalViewController
[appDelegate.splitViewController presentModalViewController:myModalViewController animated:NO];
[appDelegate.splitViewController dismissModalViewControllerAnimated:NO];

[appDelegate.window insertSubview:myModalViewController.view atIndex:0];
[appDelegate.splitViewController.view removeFromSuperview];

I'm having same problem.

In my project splitViewController is added as subview on window. And it receives rotation messages normally. But when I try to add my "modal" viewController as subview on window it does not receive rotation messages. Looks like rotation messages receive only subview at index 0. So I resolved it in this way:

Showing "modal" viewController

[appDelegate.window insertSubview:myModalViewController.view atIndex:0];
[appDelegate.splitViewController.view removeFromSuperview];

Hiding "modal" viewController

[appDelegate.window insertSubview:appDelegate.splitViewController.view atIndex:0];
[myModalViewController.view removeFromSuperview];

But there is one defect in this solution: a modalViewController will not load its view right after calling "[appDelegate.window insertSubview:myModalViewController.view atIndex:0]" method. To fix this defect I just present it as modal for a moment:

Showing "modal" viewController:

// present and dismiss methods are called to cause viewDidLoad in modalViewController
[appDelegate.splitViewController presentModalViewController:myModalViewController animated:NO];
[appDelegate.splitViewController dismissModalViewControllerAnimated:NO];

[appDelegate.window insertSubview:myModalViewController.view atIndex:0];
[appDelegate.splitViewController.view removeFromSuperview];
夜深人未静 2024-12-17 00:41:48

我在这里遇到同样的问题:不工作方向通知在模态下的VIewController中,使用iOS5

要在 mainController 中调用您想要的方法,您必须在模态中使用这些魔术线,就在控制旋转的方法中:

yourProjectAppDelegate *delegate = (yourProjectAppDelegate*) [[UIApplication sharedApplication]delegate];
yourProjectViewController *i=((yourProjectViewController *)delegate.window.yourConfigurationOfController);
[i didRotateFromInterfaceOrientation:interfaceOrientationReceived];

在 i id 中,您拥有与以下相同的对象:yourConfigurationOfController,我认为在本例中为 UISPlit。如果 i 不是您的 uiSplit,您可以通过变量级联到达。 interfaceOrientationReceived 是在模态中接收到的方向:

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation

希望能有所帮助!
祝你好运!

(抱歉我的英语:))

I´m having same problem here: Not working Orientation Notifications in VIewController under modal, with iOS5.

To call the method you want in the mainController you must use those magic lines in the modal, just in the method controlling rotating:

yourProjectAppDelegate *delegate = (yourProjectAppDelegate*) [[UIApplication sharedApplication]delegate];
yourProjectViewController *i=((yourProjectViewController *)delegate.window.yourConfigurationOfController);
[i didRotateFromInterfaceOrientation:interfaceOrientationReceived];

In i id, you have the same object you uses as: yourConfigurationOfController, in this case UISPlit, i think. If i, is not your uiSplit you can arrive by cascade of variables. interfaceOrientationReceived is the orientation received in the modal in:

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation

Hope could help!
Good luck!

(Apologize my English :))

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文