Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting MonoTouch.Dialog UITableView position?

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);
    }
}
like image 205
Rob Gibbens Avatar asked Nov 15 '22 05:11

Rob Gibbens


2 Answers

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!

like image 68
Eduardo Scoz Avatar answered Dec 20 '22 09:12

Eduardo Scoz


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

like image 33
Kenny Avatar answered Dec 20 '22 08:12

Kenny