gpt4 book ai didi

ios6 - 调用 beginRefreshing 且 contentOffset 为 0 时,UIRefreshControl 不显示刺状

转载 作者:行者123 更新时间:2023-12-01 18:29:45 25 4
gpt4 key购买 nike

调用 beginRefreshing 时我看不到加载微调器

[self.refreshControl beginRefreshing];

我的 UITableViewController 子类使用 UIRefreshControl

// refresh
UIRefreshControl * refreshControl = [UIRefreshControl new];
[refreshControl addTarget:self action:@selector(refreshTableView) forControlEvents:UIControlEventValueChanged];
self.refreshControl = refreshControl;

它与用户交互完美配合(当用户放下 table 时),然后旋转器可见。

但是当我打电话beginRefreshing时在 viewDidLoad 上,我看不到微调器(仅当我向下拖动表格时)。

注释:

  • self.refreshControl引用是正确的

  • reloadData或endRefreshing并不是在beginRefreshing之后立即调用,而是有很长的时间延迟(通过网络加载数据),所以我没有取消beginRefreshing。

编辑:这只发生在 contentOffsettableView的属性(property)是 0,我打电话 [self.refreshControl beginRefreshing] 。漏洞?特点?

最佳答案

对我来说这看起来像是一个错误,因为它仅在 tableViewcontentOffset 属性为 0 时发生

我用以下代码修复了这个问题(UITableViewController 的方法):

- (void)beginRefreshingTableView {

[self.refreshControl beginRefreshing];

if (self.tableView.contentOffset.y == 0) {

[UIView animateWithDuration:0.25 delay:0 options:UIViewAnimationOptionBeginFromCurrentState animations:^(void){

self.tableView.contentOffset = CGPointMake(0, -self.refreshControl.frame.size.height);

} completion:^(BOOL finished){

}];

}
}

关于ios6 - 调用 beginRefreshing 且 contentOffset 为 0 时,UIRefreshControl 不显示刺状,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16120797/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com