设置 MonoTouch.Dialog UITableView 位置?

发布于 2024-10-05 21:16:41 字数 472 浏览 0 评论 0原文

有没有办法设置 MonoTouch.Dialog DialogViewController 的位置?我已经对 DialogViewController 进行了子类化,并在顶部添加了一个 UIToolbar,现在我想将表格视图向下移动相应的像素。

public class MyViewController : DialogViewController
{
    UIToolbar toolbar;

    public SessionsListViewController (RootElement rootElement) : base(rootElement)
    {
      this.toolbar = new UIToolbar(new RectangleF(0,0,768,44));
      this.toolbar.Items = new UIBarButtonItem[0];
      this.Add(toolbar);
    }
}

Is there a way to set the position of a MonoTouch.Dialog DialogViewController? I have subclassed DialogViewController and added a UIToolbar at the top and now I want to shift the table view down the corresponding pixels.

public class MyViewController : DialogViewController
{
    UIToolbar toolbar;

    public SessionsListViewController (RootElement rootElement) : base(rootElement)
    {
      this.toolbar = new UIToolbar(new RectangleF(0,0,768,44));
      this.toolbar.Items = new UIBarButtonItem[0];
      this.Add(toolbar);
    }
}

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

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

发布评论

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

评论(3

世俗缘 2024-10-12 21:16:41

我永远无法更改 MonoTouch.Dialog 中 TableView 的位置。但这不是库的问题,而是 TableViewController 的工作方式的问题,它是由 MT.Dialog 继承的。

TableViewController 类应该自动管理 TableView 的位置,并且您不应该解决这个问题。即使您使用不同的位置创建 TableView,如 miguel.de.icaza 提到的,TableViewController 也会在 WillAppear 方法期间重新排列 TableView。

当不使用 MT.Dialog 时,解决这个问题的最佳方法(例如,在屏幕的一半上有一个表格)是删除 TableViewController 并简单地使用带有 TableView 对象的 UIViewController 。您仍然可以将委托和数据源传递给 TableView,因此实际上您只是放松了 TableView 的自动定位。

我尝试将 MT.Dialog 更改为从 UIViewController 而不是 UITableViewController 继承,但这导致了很多问题,而且我始终无法完成它。也许有一天我会这么做。

我很想听听我对此是错的!

I was never able to change the position of the TableView in the MonoTouch.Dialog. It's not a problem of the library though, its how the TableViewController works, which is inherited by MT.Dialog.

The TableViewController class is supposed to manage the positioning of the TableView automatically, and you're not supposed to work around that. Even if you create the TableView with a different position, like miguel.de.icaza mentioned about, the TableViewController will rearrange the TableView during the WillAppear method.

When not using MT.Dialog, the best way to work aound this, and to for example, have a table on just half of the screen is to drop the TableViewController and simply use a UIViewController with a TableView object. You can still pass the delegate and datasource to the TableView, so effectively you just loose the automatic positioning of the TableView.

I tried to change MT.Dialog to inherit from UIViewController instead of UITableViewController, but that caused lots of problems and I was never able to finish it. Maybe someday I'll do it.

I would love to hear I'm wrong about this though!

眼眸里的快感 2024-10-12 21:16:41

为了解决类似的问题,我更改了DialogViewController的派生链以继承UIViewController并直接创建UITableView。这允许我使用位图作为背景,唯一的方法就是稍微改变一下周围的东西。我计划将其检查到源树中,我们进行任何其他更新和代码清理,但需要清理一些接口

In order to get around a similar issue, I changed the derivation chain of DialogViewController to inherit UIViewController and create the UITableView directlyinstead. This allowed me to use a bitmap as the background and the only way to do that is to change things around a bit. I plan on checking this into the source tree we any other updates and code clean up, but need to clean a number of the interfaces up instead

千鲤 2024-10-12 21:16:41

只需重写 MyViewController 中的 MakeTableView 方法即可,默认实现是:

return new UITableView (bounds, style)

因此您所要做的就是更改传递的边界。

Just override the MakeTableView method in MyViewController, the default implementation is:

return new UITableView (bounds, style)

So all you have to do is change the bounds passed.

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