UISplitViewController 和 UINavigationController

发布于 2024-12-05 03:29:49 字数 189 浏览 0 评论 0原文

我是 iOS 世界的初学者。 我想要一个基于 UISplitViewController 的应用程序,但是在某些情况下,详细视图上的按钮(即 UINavigationController)将在整个屏幕上打开一个 UI(带有后退按钮,该按钮将返回到 splitViewController)。 唯一的选择(来自苹果的合法选择)是使用 ModalView 进行建模吗?

I'm a beginner in the iOS world.
I would like to have an app that is based on UISplitViewController, however on some cases a button on the detail view (which is UINavigationController) will open a UI on the entire screen (with back button which will take back to splitViewController).
Does the only option (legitimate from apple), is modeling it with ModalView?

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

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

发布评论

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

评论(1

孤蝉 2024-12-12 03:29:49

我不确定它是否是“HIG友好的”,但是你可以实现一些东西,当用户单击按钮时,你向你的AppDelegate发送一条消息,并告诉它用你的fullScreenViewController交换你的splitViewController在窗口水平。

例如,在您的 AppDelegate.m 中:

- (void)showFullScreenController
{
    if (self.splitViewController.superview != nil) {    // Just check that the split view controller is currently showing
        FullScreenViewController *newFullScreenController = [[FullScreenViewController alloc] initWithNibName:@"FullScreenViewController" bundle:nil];
        self.fullScreenController = newFullScreenController;
        [newFullScreenController release];

        [self.splitViewController viewWillDisappear:YES];    // "YES" assumes you are animating the transition
        [self.fullScreenController viewWillAppear:YES];

        // Remove old view and add new one.
        [self.splitViewController.view removeFromSuperview];
        [window addSubview:self.fullScreenController.view];

        [self.splitViewController viewDidDisappear:YES];
        [self.fullScreenController viewDidAppear:YES];

        self.splitViewController = nil;
    }
}

通过利用相应的 else 语句并加载 splitViewController<,可以轻松将该方法转换为“视图切换”方法/代码> 相反。

希望这有帮助。

I'm not sure off the top of my head whether it's 'HIG-friendly', but you could implement something whereby when the user clicks the button, you send a message back to your AppDelegate and tell it to swap your splitViewController with your fullScreenViewController at the window level.

For example, in your AppDelegate.m:

- (void)showFullScreenController
{
    if (self.splitViewController.superview != nil) {    // Just check that the split view controller is currently showing
        FullScreenViewController *newFullScreenController = [[FullScreenViewController alloc] initWithNibName:@"FullScreenViewController" bundle:nil];
        self.fullScreenController = newFullScreenController;
        [newFullScreenController release];

        [self.splitViewController viewWillDisappear:YES];    // "YES" assumes you are animating the transition
        [self.fullScreenController viewWillAppear:YES];

        // Remove old view and add new one.
        [self.splitViewController.view removeFromSuperview];
        [window addSubview:self.fullScreenController.view];

        [self.splitViewController viewDidDisappear:YES];
        [self.fullScreenController viewDidAppear:YES];

        self.splitViewController = nil;
    }
}

This method can easily be turned into a 'view switching' method by utilising the corresponding else statement and loading the splitViewController instead.

Hope this helps.

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