初始加载时导航控制器后面的 UITableViewController 中的 UITableView

UITableView in UITableViewController behind navigation controller on initial load

在我的 UITableViewController 初始加载时,第一行隐藏在导航后面,但如果我推送到另一个视图并 return 到此 UITableViewController,它会正确加载并且第一行不会被遮挡。我想不通这个。

这是 table 初始加载的屏幕截图,右边的是我 return 从通过单击行推送的视图之一

这是我的控制器代码:

class AccountInfoTableViewController: UITableViewController{

var delegate: AccountInfoTableViewDelegate?

override func viewDidLoad() {
    super.viewDidLoad()
    self.navigationController?.topViewController.title = "Account Info"
    self.automaticallyAdjustsScrollViewInsets = true
    println("NAV BAR HEIGHT \(self.navigationController?.navigationBar.frame.size.height)") // 44.0
// prints NAV BAR HEIGHT 44.0

}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
}

override func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
    return 70
}

override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
    if let cell = tableView.cellForRowAtIndexPath(indexPath){
        delegate?.accountInfoTableRowClicked(cell.textLabel!.text!)
    }
}

}

可能的重要提示:

这个 UITableViewController 用于标签栏控制器

添加了更多细节和代码

故事板中的 UITableViewController 是否嵌入到 UINavigationController 中?这样做,你应该是金色的。您是否尝试过将顶部内容偏移量(通过故事板)手动调整为 44?

看看你的其他问题,我想知道将 UITabBarController 嵌入 UINavigationController 是否是同样的问题。如果是这样的话,再次回顾一下,控制器层次结构应该如下:

第一个 UINavigationController -> 第一个 UITableViewController 第二个 UINavigationController -> 第二个 UITableViewController 最后,将上述两个 UINavigationControllers 添加到 UITabBarController 的 viewControllers 数组中。

希望对您有所帮助!