iPad SplitViewController 具有纵向模式菜单,如设置应用程序

发布于 2024-08-29 02:50:26 字数 109 浏览 4 评论 0原文

我想在我的 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 技术交流群。

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

发布评论

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

评论(8

﹏半生如梦愿梦如真 2024-09-05 02:50:26

这就是您需要的魔法:

此方法位于 UISplitViewControllerDelegate 中,可在 iOS 5.0 上使用

- (BOOL)splitViewController: (UISplitViewController*)svc shouldHideViewController:(UIViewController *)vc inOrientation:(UIInterfaceOrientation)orientation  __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_5_0);
{
    return NO;
}

This is the magic you need:

This method is in UISplitViewControllerDelegate, available on iOS 5.0

- (BOOL)splitViewController: (UISplitViewController*)svc shouldHideViewController:(UIViewController *)vc inOrientation:(UIInterfaceOrientation)orientation  __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_5_0);
{
    return NO;
}
宫墨修音 2024-09-05 02:50:26

您绝对应该看看 Matt Gemmell 的 MGSplitViewController

MGSplitViewController是一个开放的
源替换
UISplitViewController,具有各种
有用的增强功能。

You should definitely have a look at Matt Gemmell's MGSplitViewController.

MGSplitViewController is an open
source replacement for
UISplitViewController, with various
useful enhancements.

流云如水 2024-09-05 02:50:26

不幸的是,这是一个未记录的方法(即私有 API)。

[splitViewController setHidesMasterViewInPortrait:NO];

我认为您需要创建一个自定义视图控制器,其中包含一个表视图(作为主控制器)和另一个通用子视图(作为详细控制器)来模拟这一点。

Unfortunately, it's an undocumented method (i.e. private API).

[splitViewController setHidesMasterViewInPortrait:NO];

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.

日记撕了你也走了 2024-09-05 02:50:26

获得所需效果的最简单方法可能就是不使用 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.

半仙 2024-09-05 02:50:26

正如 ccwasden 所说,从 iOS8 开始,shouldHideViewController 已被弃用。在 Objective-C 中,使用...

splitViewController.preferredDisplayMode = UISplitViewControllerDisplayModeAllVisible;

As ccwasden stated, shouldHideViewController is deprecated as of iOS8. In Objective-C, use...

splitViewController.preferredDisplayMode = UISplitViewControllerDisplayModeAllVisible;
纵性 2024-09-05 02:50:26

由于 shouldHideViewController 在 iOS8 中已被弃用,因此您需要使用它(Swift):

splitViewController.preferredDisplayMode = UISplitViewControllerDisplayMode.AllVisible

Since shouldHideViewController is deprecated in iOS8, you will need to use this instead (Swift):

splitViewController.preferredDisplayMode = UISplitViewControllerDisplayMode.AllVisible
甜味拾荒者 2024-09-05 02:50:26

有些人在我们的博客上问了我同样的问题,我找到了解决方案。您可以在我的博客文章的末尾找到它 您的第一个分割视图控制器|海边

一般来说,您所要做的就是创建 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 method willAnimateRotationToInterfaceOrientation: duration: and adjust your master and detail views when the interface orientation will change to portrait mode.

Cheers,
Andreas

向地狱狂奔 2024-09-05 02:50:26

在 Swift 中:

splitViewController.preferredDisplayMode = .allVisible

In Swift:

splitViewController.preferredDisplayMode = .allVisible

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