在iOS 7上打破tableView.contentInset [英] tableView.contentInset broken on iOS 7

查看:300
本文介绍了在iOS 7上打破tableView.contentInset的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在UITableView上设置contentInset似乎不适用于iOS 7:

Setting the contentInset on a UITableView doesn't seem to work on iOS 7:

self.tableView.contentInset = UIEdgeInsetsMake(0, 0, 100, 0); 
// Works on iOS 6, nothing happens on iOS 7

我试过设置在viewDidLoad中 self.automaticallyAdjustsScrollViewInsets ,仍然没有。

I've tried setting self.automaticallyAdjustsScrollViewInsets to NO in viewDidLoad, still nothing.

我做错了什么?有没有新的方法来执行此操作或解决方法?

What am I doing wrong? Is there a new way to do this or a workaround?

推荐答案

将此代码移动到视图控制器的 -viewDidLayoutSubviews 方法为我修复了这个。

Moving this code into the view controller's -viewDidLayoutSubviews method fixed this for me.

-(void)viewDidLayoutSubviews {
    [super viewDidLayoutSubviews];
    self.tableView.contentInset = UIEdgeInsetsMake(0, 0, 100, 0); 
}

感谢Apple提供您不存在的文档!

Thanks Apple for your non-existent documentation on this!

这篇关于在iOS 7上打破tableView.contentInset的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆