在我的 UITableViewController 的初始加载中,第一行隐藏在导航后面,但是如果我推送到另一个视图并返回到此 UITableViewController ,它会正确加载并且第一行不会被遮挡。我想不通这个问题。
这是表格初始加载的屏幕截图,右边的屏幕截图是我从通过单击一行推送的视图之一返回后的屏幕截图
这是我的控制器代码:
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 用于标签栏控制器
添加了更多细节和代码在这个问题中 https://stackoverflow.com/questions/29016261/swift-table-in-tabcontroller-only-is-positioned-correctly-if-its-the-first-tab
看看你的其他问题,我想知道将 UITabBarController 嵌入 UINavigationController 中是否存在同样的问题。如果是这样的话,再次回顾一下,控制器层次结构应该如下所示:
第一个 UINavigationController -> 第一个 UITableViewController
第二个 UINavigationController -> 第二个 UITableViewController
最后,将上述两个 UINavigationController 添加到 UITabBarController 的 viewControllers 数组中。
希望有帮助!
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)