How do I pad a UITableView horizontally from the edges of screen?

DaleBinghamDaleBingham USUniversity

I am Subclassing the DialogViewController to have a consistent look and feel for my Dialog TableViews

public class ThemedDialogViewController : DialogViewController
{
    public ThemedDialogViewController  (UITableViewStyle style, RootElement root, bool pushing) 
        : base (style, root, pushing) 
    {
    }

    public override void LoadView () 
    {
        base.LoadView ();

                    this.TableView.ContentInset = new UIEdgeInsets (0f, 10f, 0f, 10f);
        this.TableView.BackgroundView = null;
        this.TableView.BackgroundColor = UIColor.FromRGB(233f/255f,128f/255f,35f/255f);
    }

}

I am trying to evenly space the tableview 10 from the sides of the window, but this only sets the tableview in 10 from the left, the right remains unchanged. I realized that there was an extra 10 to the right of the table however. Which leads me to believe I actually need to shrink the width of the table somehow. I tried to do this in the subclass but it had no effect:
this.TableView.Frame = new RectangleF(0,0,this.TableView.Bounds.Size.Width-60, this.TableView.Bounds.Size.Height);

However, I did try the above in the DialogViewController ViewDidLoad and it worked but there was a jumping effect in the UI which I of course do not want.

Any ideas on how to achieve this? Much appreciated.

Answers

  • RockMeAmadeusRockMeAmadeus USMember ✭✭

    did you try a negative value for the right inset?

  • DaleBinghamDaleBingham USUniversity

    I did try that but it didn't work. I think I really need to make the width of the table something like:
    Width of screen - 20
    Then have it center inside the screen somehow....
    Like I said in the original post, the inset seemed to make the horizontal scroll space larger, without actually making the tableview smaller....Which is why there was no room on the right.
    I thought there would be a simpler way to do this, but I can't seem to find that way :|

  • DaleBinghamDaleBingham USUniversity

    I want to do something like this:
    https://github.com/SuperYeti/MonoTouch.Dialog.Extensions

    I just can't seem to find where in this code they have the horizontal space from the edges of the screen. I don't necessarily need the vertical space in between each cell like the example....

Sign In or Register to comment.