iPad SplitViewController 具有纵向模式菜单,如设置应用程序
我想在我的 iPad 应用程序上获得 SplitView,其中左侧菜单处于纵向,例如 iPad 设置。现在,在纵向方向上,我有一个全屏内容视图,并且导航栏上有一个按钮,其中包含一个带有左侧菜单的弹出窗口。
I would like obtain a SplitView on my iPad application with my left menu in a portrait orientation such as iPad settings. For now in portrait orientation I have a content view in full screen and I have a button at NavigationBar which includes a popover with my left menu.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
这就是您需要的魔法:
此方法位于 UISplitViewControllerDelegate 中,可在 iOS 5.0 上使用
This is the magic you need:
This method is in UISplitViewControllerDelegate, available on iOS 5.0
您绝对应该看看 Matt Gemmell 的 MGSplitViewController。
You should definitely have a look at Matt Gemmell's MGSplitViewController.
不幸的是,这是一个未记录的方法(即私有 API)。
我认为您需要创建一个自定义视图控制器,其中包含一个表视图(作为主控制器)和另一个通用子视图(作为详细控制器)来模拟这一点。
Unfortunately, it's an undocumented method (i.e. private API).
I think you need to create a custom view controller containing a table view (as the master controller) and another generic subview (as the detail controller) to simulate this.
获得所需效果的最简单方法可能就是不使用 UISplitView。相反,只需创建一个普通视图,将表格视图放在其左侧,将详细视图放在右侧,然后适当地设置自动调整大小,以便所有内容在纵向和横向上都看起来正确。
The easiest way to get the effect you want may be to just not use a
UISplitView
. Instead, just create a normal view, put a table view on its left side, your detail view on the right side, and then set the autosizing stuff appropriately so that everything looks right in both portrait and landscape.正如 ccwasden 所说,从 iOS8 开始,
shouldHideViewController
已被弃用。在 Objective-C 中,使用...As ccwasden stated,
shouldHideViewController
is deprecated as of iOS8. In Objective-C, use...由于
shouldHideViewController
在 iOS8 中已被弃用,因此您需要使用它(Swift):Since
shouldHideViewController
is deprecated in iOS8, you will need to use this instead (Swift):有些人在我们的博客上问了我同样的问题,我找到了解决方案。您可以在我的博客文章的末尾找到它 您的第一个分割视图控制器|海边。
一般来说,您所要做的就是创建
UISplitViewController
的子类并重写方法willAnimateRotationToInterfaceOrientation:uration:
并在界面方向发生变化时调整您的主视图和详细视图到纵向模式。干杯,
安德烈亚斯
some people asked me the same question on our blog and I found a solution for that. You will find it at the end of my blog post Your first split view controller | Seaside.
In general, all you have to do is to create a subclass of
UISplitViewController
and override the methodwillAnimateRotationToInterfaceOrientation: duration:
and adjust your master and detail views when the interface orientation will change to portrait mode.Cheers,
Andreas
在 Swift 中:
splitViewController.preferredDisplayMode = .allVisible
In Swift:
splitViewController.preferredDisplayMode = .allVisible