1

I dragged out an entire TableViewController and made some custom cells. The cells are displaying fine. However, the entire table view hugging the top

What do I have to do to make some "padding" to the top?

.

TIMEX
  • 259,804
  • 351
  • 777
  • 1,080

2 Answers2

3

If you are not using Auto-layout, re-set the table frame with a 20 Inset on top.

If you use Auto-layout, set the top constraint's constant to 20.

Extra Stuff

enter image description here

and look at tableView.separatorInset

duan
  • 8,515
  • 3
  • 48
  • 70
  • Thanks! Do you know how I can make the separator touch the left hand side? – TIMEX Apr 10 '15 at 05:34
  • I changed the inset from 15 to / 0. The storyboard did show a slight "twitch", indicating that it moved. However, during run time, it doesn't take effect? It seems to be the same. – TIMEX Apr 10 '15 at 05:50
  • @TIMEX try to do it in code: `tableView.separatorInset = UIEdgeInsetsMake(0, 0, 0, rightInset) ` – duan Apr 10 '15 at 05:55
  • @TIMEX I found the great answer [here](http://stackoverflow.com/questions/25770119/ios-8-uitableview-separator-inset-0-not-working). Check it~ – duan Apr 10 '15 at 08:57
2

Here is the code to add padding for your tableview , add the code in viewWillAppear.

tableView.contentInset = UIEdgeInsetsMake(64.0, 0, 0, 0) 
Ajumal
  • 1,048
  • 11
  • 33