1

In order to customize a table view and add some additional controls to it, I've embedded a UTTableViewController into a Container View and placed that container View into a UIViewController.

I've followed the instructions I found here: Embedding TableView in TableViewController into another view

Storyboard

TableView is configured with four static cells, but there are unwanted table cells visible at the bottom when my app runs. As if cells are dynamic, but they are defines as static.

Looking for a suggestion what do I need to do just to show the four cells that I defined?

App

Thank you

Community
  • 1
  • 1
Paul
  • 481
  • 5
  • 15
  • 1
    In your `TableViewController viewDidLoad` set `self.tableView.tableFooterView = UIView(frame:CGRectZero)` to remove extra cells – Eric Qian Jun 22 '15 at 05:03

1 Answers1

2

You just need to add this to your code in viewDidLoad.

self.tableView.tableFooterView = [[UIView alloc]initWithFrame:CGRectZero];

EDIT: sorry i was written in objective -c

here is in swift.

self.tableView.tableFooterView = UIView(frame:CGRectZero)

The tableview will display what appear to be extra blank rows to fill out the bounds if there are not enough rows to fill one screen. It does not ask your datasource delegate for these rows because they are not really there. It is just drawing divider lines to make it look like empty rows. see comments in

https://stackoverflow.com/a/14520277/4030971

I think this will help.

Community
  • 1
  • 1
Mahesh Agrawal
  • 3,348
  • 20
  • 34
  • btw, is there a way to change that dark light-grey table header background to white? – Paul Jun 22 '15 at 05:45
  • change it in viewForHeaderInSection function. – Mahesh Agrawal Jun 22 '15 at 05:52
  • Thank you so much! I have another question related to the same view controller setup. I started a new post. http://stackoverflow.com/questions/30991840/cut-off-uitableviewcontroller-when-embedded-into-a-container-in-a-uiviewcontroll – Paul Jun 23 '15 at 00:12