ios - 添加自定义 Segues 后 UITableView 在屏幕上的偏移量

标签 ios swift uitableview uistoryboard

我最近不得不将我的一个 View Controller 从 TableView Controller 更改为带有 UITableView 的普通 View Controller ,在这样做时,我遇到了多个问题。

我终于得到了数据来填充我的表格,但现在我的内容就在屏幕之外,不能滚动或让我单击单元格(看起来表格 View 从 (-20, 0) 或其他位置开始) :

[![在此处输入图像描述][1]][1]

我只需要约束元素,UITableView 和它下面的白色小 View 。

所以我给UITableView设置了约束:Top:Superview,Trailing:Superview,Leading:Superview,Bottom:View + 2;和 View :宽度:320,高度:50,底部:底部布局+2,对齐中心X: super View 。非常简单的约束,但是当我运行时我得到这个:

enter image description here

我不明白为什么。在 Main.Storyboard (预览)中我得到这个:

enter image description here

所以根据预览来看,应该显示得很完美。有谁知道我为什么会出现这种行为?

最佳答案

您的 UIViewController 中有一个 UINavigationBar。因此,您可能应该将 UITableView 的顶部约束设置为 TopLayoutGuide 等于 0,而不是 superView。 它将把您的 TableView 完美地设置在导航栏下方。现在它位于导航栏后面。

关于ios - 添加自定义 Segues 后 UITableView 在屏幕上的偏移量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36314617/

相关文章:

xcode - swift : Auto Layout Issue

ios - 我们可以使用较低版本的 pay pal sdk 和最新的 xcode 和 swift 版本吗

iphone - 我应该使用 self.tableView 还是单独使用 tableView?

ios - UITableView 不使用 TabBar Controller 加载数据

ios - 滚动 UIScrollView 会改变它的 subview 框架

在低功耗模式下,iOS 应用程序在 NSOperationQueue 上崩溃

ios - Interstitial Ads(iAd 和 Spritekit)出错

ios - 如何更改 Google Analytics for iOS 存储其 sqlite 文件的位置?

ios - HealthKit 请求授权(toShare :, 读取,完成 : ) : is there are way to know whether it was promped at least once?

ios - UITableView 从 NIB 文件加载自定义单元格抛出 NSInternalInconsistencyException