iOS TableViewController滚动状态栏下的内容和导航栏 [英] iOS TableViewController Scrolling away content and navigation bar under status bar

查看:251
本文介绍了iOS TableViewController滚动状态栏下的内容和导航栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用TableViewController,并且在顶部添加了自己的导航栏,以匹配我拥有的其他tabBar页面.

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

我不得不在顶部放置一个空视图以降低表格视图的起点,这样它就不会覆盖我的navBar,这已经很烦人了.

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.

现在看起来不错,除了当我向上滚动列表时,navBarTableView都位于状态栏下.

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

我希望我的navBar保持原样,并且TableView滚动时不要进入状态栏.

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

Xcode 7.1 swift 2.0 iOS 9

推荐答案

在创建这种结构(表+其他元素)时,最好的方法是实际使用包含TableView和其他元素的ViewController (如您的导航).不要尝试将不属于表本身的元素放入表中.

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.

这篇关于iOS TableViewController滚动状态栏下的内容和导航栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆