我有一个导航设置,顶部有一个UITabBarController。 然后我有一个选项卡,它通过创建放置到UINavigationController中的UIViewController实例化,如下所示:
UIViewController *testVC = [UIViewController new]; // Has UITableView as subview UINavigationController *testNavVC = [[UINavigationController alloc] initWithRootViewController:testVC]; [self setViewControllers:@[testNavVC]];arris的问题在于testVC UIViewController中的UITableView。 该表在顶部正确显示,并且正确位于UINavController的导航栏下方。 但是,当您将表格视图滚动到底部时,表格视图中的最后一行将被截断在屏幕底部。 我发现我可以将底部内容插入设置为100(值将根据行高度而不同)以正确显示内容。 我觉得我不应该这样做,我正在寻找更好的解决方案。
如何正确添加以这种方式嵌套的UITableView?
作为旁注,当使用UITableViewController而不是带有添加的UITableView的UIViewController时,这一切都能正常工作。 在我的情况下,我需要使用后一种选择。
I have a navigation setup where at the top there is a UITabBarController. I then have a tab, which is instantiated by creating a UIViewController placed into a UINavigationController like so:
UIViewController *testVC = [UIViewController new]; // Has UITableView as subview UINavigationController *testNavVC = [[UINavigationController alloc] initWithRootViewController:testVC]; [self setViewControllers:@[testNavVC]];The problem that arrises is with the UITableView inside the testVC UIViewController. The table displays properly at the top and is correctly situated underneath the UINavController's nav bar. When you scroll the table view to the bottom, however, the final rows in the table view will be cut off at the bottom of the screen. I found out that I can set the bottom content inset to 100(value will differ based on row height) to correctly display the content. I don't feel like I should need to do that though, and am looking for a better solution.
How can I properly add a UITableView that is nested in this way?
As a side note this all works correctly when using a UITableViewController rather than a UIViewController with the added UITableView. In my case I am needing to use the latter option.
最满意答案
您可以尝试使用bottomLayoutGuide属性调整UITableView底部插入而无需硬编码:
tableView.contentInset = UIEdgeInsetsMake(0.0, 0.0, self.bottomLayoutGuide.length, 0.0);它表示内容的最低垂直范围,可以在iOS 7中使用。
作为替代方法,您可以使用此值为UITableView创建底部NSLayoutConstraint。
All of my code was done programmatically and the problem ended up being that I setup the UITableView with the views frame. I switched it over to use autolayout instead and it worked great!
更多推荐
发布评论