UIRefreshControl 默认添加奇怪的插图

Posted

技术标签:

【中文标题】UIRefreshControl 默认添加奇怪的插图【英文标题】:UIRefreshControl adds strange inset by default 【发布时间】:2014-10-24 23:24:35 【问题描述】:

我正在将 UIRefreshControl 添加到一个相当默认的 UITableView 中...

ios SDK 8.1 self 是 UITableViewController 的一个实例

UIRefreshControl *refreshControl = [[UIRefreshControl alloc] init];
refreshControl.backgroundColor = [UIColor flatPeterRiverColor];
refreshControl.tintColor = [UIColor whiteColor];
[refreshControl addTarget:self
                   action:@selector(triggerSync)
         forControlEvents:UIControlEventValueChanged];
[self setRefreshControl:refreshControl];

会发生以下情况:

有一个奇怪的顶部插图,我从未设置过,它仅在设置 UIRefreshControl 时出现。有谁之前经历过这个吗?我很确定它在 iOS 7.0 中运行良好。

【问题讨论】:

【参考方案1】:

老话题,我不知道你是否还在经历它,但对于那些想知道如何解决它的人,我找到了一个快速的解决方案。

您只需在部分中设置标题的高度。 我先尝试了 0,但没有结果。

所以我将所有部分都设置为 1.0 并且它工作正常。

希望有帮助

【讨论】:

实际上,这似乎是由于automaticallyAdjustsScrollViewInsets 属性。

以上是关于UIRefreshControl 默认添加奇怪的插图的主要内容,如果未能解决你的问题,请参考以下文章

UIRefreshControl 在启用 preferLargeTitles 的情况下向下滚动时出现奇怪的跳转

移除 UIRefreshControl 默认微调器

如何更改 UIRefreshControl 的字体和颜色

如何自定义 UIRefreshControl 以使下拉高度低于默认值

UIRefreshControl 闪烁与自定大小的单元格

将目标添加到 UIRefreshControl()