UITableView in UITableViewController behind navigation controller on initial load

混江龙づ霸主 提交于 2019-12-01 11:52:33

问题


On the initial load of my UITableViewController the first row gets hidden behind the navigation, but if I push to another view and return to this UITableViewController it is loaded correctly and the first row isn't obscured. I can not figure this one out.

Here's a screen shot of the initial load of the table and the one on the right is after I return from one of the views that was pushed by clicking a row

Here's my controller code:

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!)
    }
}

}

POSSIBLE IMPORTANT NOTE:

This UITableViewController is used in a tab bar controller

Added some more detail and code in this question


回答1:


looking at your other question, I'm wondering if it's the same issue with having the UITabBarController embedded within a UINavigationController. If that's the case, the Just to recap again, the controller hierarchy should be as follows:

First UINavigationController -> First UITableViewController Second UINavigationController -> Second UITableViewController Finally, both of the above UINavigationControllers added to the UITabBarController's viewControllers array.

Hope that helps!




回答2:


Is the UITableViewController embedded in a UINavigationController in the storyboard? Do this, and you should be golden. Have you tried manually adjusting the top content offset (via the storyboard) to 44?



来源:https://stackoverflow.com/questions/28994939/uitableview-in-uitableviewcontroller-behind-navigation-controller-on-initial-loa

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