如何在横向中全屏UISplitViewController的DetailView

发布于 2024-12-01 20:01:54 字数 710 浏览 0 评论 0原文

我有一个带有公共详细视图(右侧)的 UISplitViewController 。

我在横向的detailView上添加了一个按钮,当单击该按钮时,ma​​sterView(左侧)将隐藏并且detailView将变为全屏。就像 iPad 版 Dropbox 应用程序的行为

现在,我可以隐藏 masterView,但无法通过仅设置DetailViewController.view 的框架将DetailView 更改为全屏。

splitview左侧的宽度= 321, 更改前的DetailViewController.view.frame为{{321,0}, {703, 748}}。

如果我通过以下代码更改detailview.frame,则没有发生任何更改

self.frame = CGRectMake(0, 0, 1024, 748);

如果我使用以下代码,它会改变位置,但这不是全屏

self.frame = CGRectMake(0, 0, 703, 748);

我发现如果我更改框架的尺寸(例如 704)大于其原始宽度,框架的位置不会改变。

如何使细节视图在横向下变成全屏宽度? 任何建议将不胜感激。

I have a UISplitViewController with a common detailView (right side).

I add a button to detailView in landscape orientation, when the button is clicked, the masterView(left side) will be hide and detailView will become fullscreen. just like the behavior of the Dropbox app for iPad

Now, I can hide the masterView but cannot change detailView to fullscreen by just setting detailviewController.view's frame.

width of splitview's left side = 321,
and the detailviewController.view.frame is {{321,0}, {703, 748}} before changed.

If I change the detailview.frame by following code, there is no change happened.

self.frame = CGRectMake(0, 0, 1024, 748);

And It will change position if I use following code, but that's not fullscreen.

self.frame = CGRectMake(0, 0, 703, 748);

I found if I change the frame with a larger size (ex. 704) than its origin width, the position of the frame will not change.

How to make a detailview to become whole screen width under landscape orientation?
Any suggestion will be very appreciated.

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

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

发布评论

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

评论(3

梦回梦里 2024-12-08 20:01:54

我看到另一种可能性使用 UIView 的 + transitionFromView:toView:duration:options:completion: 方法将 UISplitViewCintroller 的视图交换为 UIWindow 视图中的其他全屏 UIView 实例

I see another possibility to use + transitionFromView:toView:duration:options:completion: method of UIView to exchange UISplitViewCintroller's view for other fullscreen UIView instance in UIWindow view

鹤舞 2024-12-08 20:01:54

我在下面的链接中找到了一个解决方案来创建自定义 splitview 控制器,您可以调整它以获得所需的效果。我认为不可能改变普通 UISplitViewController 的主视图和详细视图的框架大小(我在 iOS5 中尝试过,但没有成功)。

自定义 SplitView

-anoop

I have found a solution in the below link to create a custom splitview controller, you can tweak this to get the desired effect. I dont think it is possible to change the frame size of master and detail view of the normal UISplitViewController (I tried in iOS5, it didnt work).

Custom SplitView

-anoop

但可醉心 2024-12-08 20:01:54

这可以通过 viewWillTransitionToSize 方法来完成,只要我们的设备方向发生变化,就会调用该方法,并且以下内容将帮助您实现您想要的。

-(void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator{
    self.splitViewController.preferredDisplayMode = UISplitViewControllerDisplayModePrimaryHidden;
}

preferredDisplayMode 可用于使主视图隐藏、显示或覆盖在详细视图控制器上。

This can be done with the method viewWillTransitionToSize,this method will be called whenever our device orientation changes and in that the following will help you achieve what you want.

-(void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator{
    self.splitViewController.preferredDisplayMode = UISplitViewControllerDisplayModePrimaryHidden;
}

The preferredDisplayMode can be used to make the master View hide or show or overlay over the Detail View controller.

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