我已将 UIRefreshControl
添加到 UITableView
中,即使它不可见,它似乎也在持续动画。
通过运行 frankly_map "view:'_UIRefreshControlModernReplicatorView'", "isAnimating"
Frank 控制台显示,错误的 View 实际上是私有(private) UIKit _UIRefreshControlModernReplicatorView
,它继续在屏幕外显示动画。
关于为什么会发生这种情况或如何停止动画有什么建议吗?
复制存储库 => https://github.com/samst0r/UIRefreshControlFrank
我已经包含了代码的重要部分 =>
- (void)viewDidLoad
{
[super viewDidLoad];
UIRefreshControl *refreshControl = [[UIRefreshControl alloc] init];
[refreshControl addTarget:self
action:@selector(refresh)
forControlEvents:UIControlEventValueChanged];
self.refreshControl = refreshControl;
}
#pragma mark - Other
- (void)refresh {
double delayInSeconds = 2.0;
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC));
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
[self.refreshControl endRefreshing];
});
}
最佳答案
在隐藏之前,请使用以下代码停止刷新:
[refrshControl endRefreshing];
关于ios - UIRefreshControl 持续动画,即使它不可见,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21629301/