UIRefreshControl持续动画,即使它不可见

时间:2014-02-07 13:42:23

标签: ios uitableview animation uirefreshcontrol frank

我已将UIRefreshControl添加到UITableView并且它似乎是连续动画,即使它不可见。

通过frankly_map "view:'_UIRefreshControlModernReplicatorView'", "isAnimating"运行 Frank控制台显示错误的视图实际上是私有的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];
    });
}

1 个答案:

答案 0 :(得分:2)

在隐藏之前,请使用以下代码停止刷新:

[refrshControl endRefreshing];