aresz
aresz

Reputation: 2649

Setting tableview to static still displays a lot of rows

I'm attempting to display a static tableview in my UITableViewController as I only want to display 1 row. I've set the tableview's content to Static Cells already but I still get more rows than I want to appear when I deploy it to my test device. I've also explicitly set the number of rows and sections in my UITableViewController subclass but still the results are the same.

I've attached some screenshots to further explain the result I'm getting.

Here's a screenshot of what my tableview controller looks like in the storyboard

storyboard

Here's a screenshot of the attribute inspector of my table view enter image description here enter image description here

Here's a screenshot of my UITableViewController subclass enter image description here

Finally, here's a screenshot of what the tableview looks like on the test device enter image description here

As you can see even though I set the number of static rows to 1, I still get multiple rows. I'm not sure why this is happening but if anyone has any ideas, I'd appreciate the help.

Thanks

Upvotes: 2

Views: 298

Answers (2)

Brian Nickel
Brian Nickel

Reputation: 27550

An alternative to .grouped style, if you have to use .plain, is to attach a zero height tableFooterView to the table view since it won't draw separators below a footer.

You can either drag a view into the table view in Interface Builder, or add it in your viewDidLoad:

override func viewDidLoad() {
    super.viewDidLoad()
    tableView.tableFooterView = UIView()
}

Upvotes: 0

nathangitter
nathangitter

Reputation: 9777

Change the table view's style to Grouped.

This should give the effect you desire:

table view screenshot with grouped style

Upvotes: 3

Related Questions