How to get a padding inside TableView?

I have a TableView with a dark transparent background which I'd like to have a padding I tried to accomplish that using contentInsets, contentSize and contentOffset:

CGFloat padding = 10.0f;
CGSize size = self.tableView.bounds.size;
size.width -= (padding*2);
size.height -= (padding*2);
self.tableView.contentSize = size;
self.tableView.contentInset = UIEdgeInsetsMake(padding, padding, padding, padding);
self.tableView.contentOffset = CGPointMake(-padding, -padding);

That doesn't work. I get the padding, but neither are the cells resized nor respositioned.

I know, I could nest the TableView inside another View, but there should be another solution.

EDIT:

I actually had a misconception as to the meaning of 'contentSize'. It's not the viewport's size but the actual size of, you name it, the content. So I probably will have to..

  1. resize the individual cells if possible (might collide with the TableView's layout process)
  2. apply a content offset to the TableView as above

Answers


For width, you are going to have to mess with each cells frame. as for top and bottom inset, use setContentInset:


Need Your Help

ping in monotouch

iphone ios monotouch ping

I'm wondering why does some monotouch features works well in simulator but fails on real device?

JPA Multiple Embedded fields

java hibernate jpa java-ee

Is it possible for a JPA entity class to contain two embedded (@Embedded) fields? An example would be:

Flex 4 change popup's overlay color

flex4

How can I change the color or the transparency of the popup's overlay? I want to have another color and alpha 1.