自定义 UIViewController 旋转过渡

发布于 2024-11-05 20:12:23 字数 279 浏览 1 评论 0原文

我有几个 UIViewController 子类。一个显示网格,另一个本质上是网格上图块的“详细视图”。用户点击图块,详细信息视图就会从网格展开以填充屏幕。

我已经成功地使视图正确地动画化,并且可以完美地显示每个视图的内容。当设备旋转时我的问题就出现了。我已将详细视图显示为网格视图的子视图,因此当我旋转设备时,网格视图控制器会获取旋转调用,而不是详细视图。

由于这是一个自定义动画,我无法使用标准的弹出和推送视图控制器方法。我是否必须调用一个方法来使该视图控制器负责处理旋转直到它被解除?

谢谢

I have a couple of UIViewController subclasses. One that displays a grid and another that is essentially the 'detail view' for the tile on the grid. The user taps a tile and the detail view expands from the grid to fill the screen.

I have managed to get the views to animate properly and can display the content of each view perfectly. My problem comes when the device is rotated. I have displayed the detail view as a subview of the gridview and so when I rotate the device, the grid view controller gets the rotation calls, not the detail view.

As this is a custom animation, I couldn't use the standard pop and push view controller methods. Is there an method that I have to call to make this view controller responsible for handling rotation until it is dismissed?

Thanks

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

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

发布评论

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

评论(2

猫性小仙女 2024-11-12 20:12:23

如果我理解正确,您旋转网格视图控制器并且它做出响应,但是“详细视图”视图控制器没有正确更改?

如果是这种情况,我可以想到两种可能的解决方案(目前我自己也在使用)。一种解决方案是注册通知的“详细视图”。每当网格视图控制器旋转时,发送通知,“详细视图”应该根据您的需要进行响应。

另一个解决方案只是在加载“详细视图”时进行简单的检查。

if (self.view.bounds.size.height < self.view.bounds.size.width) {
    // apply the code you wish to size it for landscape mode;
}

当然,只有当屏幕旋转时“详细视图”当前不可见时,这才有效,因此发送通知可能是覆盖所有可能性的更好选择。

If I understand correctly, you rotate your grid view controller and it responds, but the 'detail view' view controller doesn't change correctly?

If this is the case, there are two possible solutions I can think of (and currently use myself). One solution would be to register the 'detail view' for a notification. Whenever the grid view controller is rotated, send the notification and the 'detail view' should respond as you want it.

The other solution is just a simple check when the 'detail view' is loaded.

if (self.view.bounds.size.height < self.view.bounds.size.width) {
    // apply the code you wish to size it for landscape mode;
}

This, of course, would only work if the 'detail view' is not currently visible when the screen is rotated, so sending a notification may be a better choice to cover all possibilities.

最舍不得你 2024-11-12 20:12:23

您可以在网格视图控制器中设置自定义委托,并在设置后将详细视图控制器注册为该委托。然后在网格视图控制器中实现 willRotateToInterfaceOrientation:duration:didRotateFromInterfaceOrientation: ,它们首先调用委托(详细视图控制器)中的相应方法,然后在 超级。

You could set up a custom delegate in the grid view controller and register the detail view controller as that delegate after it is set up. In the grid view controller you then implement willRotateToInterfaceOrientation:duration: and didRotateFromInterfaceOrientation: which first call the corresponding methods in the delegate (the detail view controller) and then in super.

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