以横向方式显示或关闭模态视图控制器

发布于 2024-12-07 21:36:00 字数 176 浏览 0 评论 0原文

我有一个 iPad 应用程序,其中包含一个带有 3 个子视图 (3 UIViewController) 的 UIViewController 视图。如果我以纵向呈现或关闭模态视图控制器,我会得到具有正确框架的视图控制器。如果我以横向方式呈现或关闭模态视图控制器,我会得到错误的框架(“{{0, -256}, {748, 1024}}”)。

I have an iPad app with a view of a UIViewController with 3 subview (3 UIViewController). If i present or dismiss a modal view controller in portait orientation I get the view controller with the right frame. If I present or dismiss the modal view controller in landscape orientation i get a wrong frame ("{{0, -256}, {748, 1024}}").

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

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

发布评论

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

评论(1

莳間冲淡了誓言ζ 2024-12-14 21:36:00

我也遇到同样的问题。我怀疑这是因为我们手动管理视图层次结构并且没有正确考虑方向变化。我将发布任何附加发现,但到目前为止,我发现您可以在模态视图控制器呈现后更正它,如下所示:

// Display modal dialog view controller "detailNav"
[self presentModalViewController:detailNav animated:YES];     
// Create a custom frame for this view, optional, but needs to be set after presenting
detailNav.view.superview.frame = customRect;                  
// Recenter the view, for example to the center of your apps main window
CGPoint center = myApp.window.center;
detailNav.view.superview.center = center;

I'm getting this same issue. I suspect it's because we're manually managing the view hierarchy and not properly accounting for orientation changes. I'll post any addition discovery, but so far I've found that you can correct the modal view controller after it's presented like so:

// Display modal dialog view controller "detailNav"
[self presentModalViewController:detailNav animated:YES];     
// Create a custom frame for this view, optional, but needs to be set after presenting
detailNav.view.superview.frame = customRect;                  
// Recenter the view, for example to the center of your apps main window
CGPoint center = myApp.window.center;
detailNav.view.superview.center = center;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文