iOS TableViewController Scrolling away content and navigation bar under status bar

穿精又带淫゛_ 提交于 2019-12-12 04:16:44

问题


I'm using a TableViewController and I've added my own navigation bar on top to match the other tabBar pages that I have.

I had to place at the top an empty view to lower the starting point of the table view so it wouldn't cover my navBar, which was already annoying.

Now it looks fine except that when I scroll up my list both navBar and TableView go under the status bar.

I want my navBar to stay where it is and the TableView not to go under the status bar when scrolling.

For starting I can't add any other stuff in my scene if not under the table view and i get that that's causing the nav bar to follow the tableview up so that's part of the problem..

Xcode 7.1 swift 2.0 iOS 9


回答1:


When creating this kind of structure (table + other elements), the best approach is to actually have a ViewController that contains a TableView and additional elements (like your navigation). Do not try to put elements, that are not part of the table itself inside the table.

Here is an example of the structure, where I have intentionally coloured the custom view (in your case the navigation) orange. As you can see, it is outside the table. This way the showing and scrolling of the table is completely separated from the other elements.




回答2:


you can try self.edgesForExtendedLayout = UIExtendedEdgeNone;



来源:https://stackoverflow.com/questions/33582824/ios-tableviewcontroller-scrolling-away-content-and-navigation-bar-under-status-b

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!