Empty white space above UITableView inside a UIVie

2019-01-22 02:08发布

I'm trying to position a TableView inside my ViewController view but leaving a 44 height gap between the bottom of the navigation bar and the top of the table. I then wanted to place a UITextField inside that gap to act as a stationary header. For some reason, the TableView has an empty white space above the start of the "Prototype Cells". Its just white space. Here is what it looks like in the storyboard.

storyboard

When viewing the app display, this is what it looks like:

app1

When scrolling the table, it goes all the way up to the correct place:

app2

7条回答
成全新的幸福
2楼-- · 2019-01-22 03:00

Try to look in the 'attribute inspector' (in the right menu) of the Participants ViewController. Check for the option 'Extend Edges' and uncheck the 'Under Top Bars', and then relocate your tableview.

Another possible solution is to just uncheck the option 'Adjust Scroll View Insets'. The reason is that when the viewController extends its edges, let's say under the top bar, the tableView's scrollView automatically adjusts its inset top, so that the content of the tableView will start exactly under the top bar. But in your case this is not needed, since your tableView itself starts under the bar.

Focus on the ViewController and got to the Attribute Inspector tab:

enter image description here

查看更多
登录 后发表回答