UISplitViewController:如果详细信息控制器是UITableView,如何获取工具栏?

发布于 2024-10-09 03:27:38 字数 432 浏览 0 评论 0原文

我查看了苹果的 有关如何在 UISplitViewController 中交换详细信息视图的示例,似乎他们将 UIToolbar 放入每个详细信息控制器中。然后,如果设备旋转,他们会隐藏工具栏或显示工具栏,并添加一个弹出按钮来显示根控制器。

我想采用这种模式,使用工具栏中的按钮在弹出窗口中显示我的根控制器,但不幸的是,我的详细控制器都是 UITableViewControllers,并且它们不允许添加除表视图。那么我该如何处理呢?周围有例子吗?

勒内

I checked out Apple's example on how to exchange detail views in the UISplitViewController and it seems that they put the UIToolbar in every detail controller. Then, if the device is rotated, they hide the toolbar or show it and add a popover button which will show the root controller.

I'd like to adopt this pattern to show my root controller in a popover using a button in the toolbar, but unfortunately, my detail controllers are all UITableViewControllers and they do not allow adding other UI elements than a table view. So how do I deal with that? Is there an example around?

René

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

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

发布评论

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

评论(2

离笑几人歌 2024-10-16 03:27:39

查看 此示例相应代码。如果我理解你的问题,这应该会告诉你如何做你想要完成的事情。

另外,仅供大家参考,另一位 MT 用户 MonoTouched MultipleDetailViews 示例您链接到上面的。

Check out this example and the corresponding code. If I understand your question, this should show you how to do what you're looking to accomplish.

Also, just as an FYI to everyone, another MT user MonoTouched the MultipleDetailViews example that you linked to above.

冬天旳寂寞 2024-10-16 03:27:38

我想我自己想通了:不要使用“UITableViewController”和 UITableView 作为 NIB 中的根视图,因为您无法将 UIToolbar 添加到表视图中。

相反:在NIB中,放置一个标准视图并在其上拖动一个UIToolbar和一个UITableView。
将标准视图连接到控制器的“视图”插座。
添加另一个插座并将其设为 UITableView。将表视图连接到它。

在代码中:让你的控制器继承自 UIViewController 而不是 UITableViewController。
向控制器添加一个属性以获取 TableView,使其看起来与 UITableViewController 兼容。

public UITableView TableView
{
get { return this.viewTableView; }
}

在 viewDidRotate 事件发生后,您现在必须调整表格视图的宽度和高度(UITableViewController 之前为您完成了这项工作):

this.TableView.Frame = new RectangleF(0, 44, this.SuperView.Frame.Width, this.SuperView.Frame.Height);

来自父视图工具栏的 44 像素 com。

我不想念 UITableViewController。我知道存在一些问题,例如编辑时自动滚动,但就我而言,这是根本不需要的。

勒内

I think I figured out by myself: DON'T use a ´UITableViewController´ and a UITableView as root view in your NIB, as you cannot add a UIToolbar to the table view.

Instead: In the NIB, put a standard view and drag a UIToolbar and a UITableView on it.
Connect the standard view to the controller's "view" outlet.
Add another outlet and make it a UITableView. Connect the table view to it.

In the code: Let your controller inherit from UIViewController and not from UITableViewController.
Add a property to your controller to get the TableView to make it look compatible to UITableViewController.

public UITableView TableView
{
get { return this.viewTableView; }
}

Upon the viewDidRotate event you will have to adjust the table views width and height now (UITableViewController did that job for you before):

this.TableView.Frame = new RectangleF(0, 44, this.SuperView.Frame.Width, this.SuperView.Frame.Height);

The 44 pixels com from the parent view's toolbar.

I don't miss UITableViewController. I know there are some issues like automatic scrolling when editing, but in my case this is simply not needed.

René

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