SplitViewController 中的 UIPopoverController

发布于 2024-11-01 04:01:59 字数 985 浏览 0 评论 0原文

我有一个相当复杂的问题,我将尽可能详细地描述它。

我有一个 iPad 应用程序和一个 SplitviewController 作为我的主视图。在纵向模式下,SplitviewController 将 Tableview 隐藏到左侧,以便 DetailviewController 只可见。到目前为止,一切都很好。

根据我的理解,您使用它的方式是,如果我点击左侧的单元格,我会将右侧的详细视图替换为我想要显示的新视图。为此,我使用 viewControllers 属性。

现在要显示弹出窗口,我在顶部有一个工具栏和一个用于显示弹出窗口的菜单按钮。

事情是这样的:

我点击一个单元格,然后用新的视图控制器替换 DetailviewController。但现在 Popovercontroller 消失了,因为它是在旧 ViewController 的标头中声明的。

问题:当我在端口模式下点击菜单按钮时,弹出窗口无法显示,因为它现在为零,因为它尚未启动。

但我能做的是:我将 iPad 旋转到横向,然后再旋转回来。弹出窗口又回来了,因为在 splitviewcontroller 的委托方法中发生了以下情况:

- (void) splitViewController: (UISplitViewController*)svc willHideViewController:(UIViewController *)aViewController withBarButtonItem:(UIBarButtonItem*)barButtonItem forPopoverController: (UIPopoverController*)pc {

    self.popoverController = pc;
}

这台电脑来自哪里?我自己怎么能做到呢。

如果我尝试重新分配 Popovercontroller,这会破坏 SplitviewController 并出现应用程序中的工件。

我希望我能很好地解释我的问题。

有什么想法吗?

I have a fairly complicated issue which I will describe as good as possible.

I have an iPad App and a SplitviewController as my main view. In Portrait mode, the SplitviewController hides the Tableview to the left, so that the DetailviewController is visible only. So far so good.

The way you use this, is, from what I understand, that if I tap on a cell to the left, I replace the Detailview to the right with a new view I want to show. To this end, I use the viewControllers property.

Now to display the Popover I have a Toolbar at the top and a Menu Button to display the Popover.

Here's the thing:

I tap on a cell, and replace the DetailviewController with a new Viewcontroller. But now the Popovercontroller is gone, since it was declared in the header of the old ViewController.

The problem: When I tap on the Menu Button in port mode, the popover cant be displayed, since it is nil now, as it wasnt initiated yet.

But what I can do is: I rotate the iPad to the landscape, and rotate it back again. The popover is back, bacause in the delegate method of the splitviewcontroller the following happens:

- (void) splitViewController: (UISplitViewController*)svc willHideViewController:(UIViewController *)aViewController withBarButtonItem:(UIBarButtonItem*)barButtonItem forPopoverController: (UIPopoverController*)pc {

    self.popoverController = pc;
}

Where does this pc come from? How can I do that myself.

If I try to re-alloc the Popovercontroller this breaks the SplitviewController and artifacts in the App appear.

I hope I explained my problem well enough.

Any ideas?

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

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

发布评论

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

评论(1

赠佳期 2024-11-08 04:02:00

看一下 Apple 的示例代码:

http://developer .apple.com/library/ios/samplecode/MultipleDetailViews/Introduction/Intro.html

它演示了如何通过点击拆分视图应用程序左侧视图中表格中的项目来在不同的详细信息视图之间切换。

Take a look at this sample code from Apple:

http://developer.apple.com/library/ios/samplecode/MultipleDetailViews/Introduction/Intro.html

It demonstrates how to switch between different detail views by tapping on items in the table in the split view app's lefthand view.

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