1

I have a new TableViewController that I dragged from the object library. It is now populated with data. When I run the app, the tableview is going all the way into the status bar. I don't think that is normal.

But I also don't see a way to resize the a tableview on the TableViewController scene. Any one have some suggestions how I should go about fixing this issue?

4thSpace
  • 43,672
  • 97
  • 296
  • 475
  • Can you show some screenshots to illustrate the problem, please? – Qbyte Dec 22 '15 at 15:49
  • @4thSpace if you solved the problem, consider closing the question by adding and accepting your answer, or, if the answer below solved if for your, closing the question by accepting it. – dfrib Dec 29 '15 at 00:17
  • You can embed the UITableViewController in a UINavigationController. Refer to this [UITableView shows under status bar](https://stackoverflow.com/q/18900428/6521116) – LF00 Jan 15 '18 at 07:41

1 Answers1

0

You can embed your TableViewController in a Navigation controller:

1. Select the TableViewController in the storyboard
2. Xcode top bar: Editor -> Embed in -> Navigation controller

If you don't want to embed your TableViewController in a nav. control, you can add padding to the table view in your viewDidLoad in your TableViewController class:

// ... in TableViewController.swift
override func viewDidLoad() {
    super.viewDidLoad()

    // add top padding to table view   
    let myTopPadding: CGFloat = 50
    self.tableView.contentInset = UIEdgeInsetsMake(myTopPadding, 0, 0, 0);

    // ...
}

Note that with this solution, however, you data will still "hit" the status bar when scrolling, although not when entering your table view. This is apparently and issue that is hard to avoid (without navigation controller) when subclassing the UITableViewController:

If you want padding also when scrolling then, based on the thread above, you're better off creating your own table via view controller -> insert table view -> ..., rather than using the finished UITableViewController "package".

Community
  • 1
  • 1
dfrib
  • 70,367
  • 12
  • 127
  • 192
  • What if you don't want to use a navigation controller? Is running up into the status bar against the HIGs? – 4thSpace Dec 22 '15 at 23:05
  • @4thSpace Edited answer to include also this case. Don't know what three-letter abbreviation HIG means so can't answer as to that (gotta love all these abbreviations). – dfrib Dec 22 '15 at 23:22