views:

464

answers:

3

I need to add some blank space to the top of my UITableView that does not effect the size of the content area. Shifting the content down or adding a blank cell is NOT what I want to do. Instead I just want an offset.

Any idea?

A: 

You can add an "empty" header view to the table... this would give the initial appearance of the table to have an offset, but once you started scrolling the offset would be gone. NOt sure that's what you want.

If you need a permanent offset and are not already using section headers, then you could create the offset similarly to above by making custom views for the section headers, especially if you just have one section, this could give you the look of a permanent offset.

I can post sample code if it sounds like either of those are what you are looking for.

A: 

Sounds like you want to wrap a 'View' around your UITableView. If you have a UITableViewController in IB the UITableView will automatically be set to the view of UITableViewController. You change view property to a normal UIView and add your UITableView in there and give it a offset.

---Edit--- I just read my post and thought it made little sense :) When you create a UITableViewController you get this (in pseudo code):

UITableViewController.view = UITableView

This means that the actual table will take up the whole space and you cannot even add other views. So you need to change the

UITableViewController.view = UIView

and add your table to that UIView

willcodejavaforfood
A: 

I'm not sure if I'm following you but I think I'm having the same predicament. In my case I must give some space to the ADBannerView at the top of the screen so what I did was in the viewDidLoad method I added:

[self.tableView setContentInset:UIEdgeInsetsMake(50,0,0,0)];

the values it takes are UIEdgeInsetsMake(top,left,bottom,right).

Jigzat