【问题标题】:Change the path needed for UIRefreshControl to go to UIControlEventValueChanged将 UIRefreshControl 所需的路径更改为 UIControlEventValueChanged
【发布时间】:2013-03-12 11:39:04
【问题描述】:

我正在尝试将UIRefreshControl添加到我的UIScrollView,但问题是它的面积太小,所以用户几乎不可能拉到所需的水平。

那么有没有办法触发这个控件的状态或者改变所需拉动手势的长度呢?

我知道,这个控件是新的,可能没有直接的方法来实现它,但也许有人发现了一个 hack?

【问题讨论】:

标签: ios uiview ios6 uiscrollview uirefreshcontrol


【解决方案1】:

找到了解决方案:为您的 scrollView 设置一个委托,并在 - (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate 中以某个偏移量刷新控件

- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate
{
  if (scrollView.contentOffset.y < -70) {
    [refreshControl beginRefreshing];
     dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{
       [self handleRefresh:refreshControl];
     });
  }
}

调度是为了在从服务器获取信息时不滞后界面。 如果您随后更新 UI 中的某些内容,请使用 dispatch_async(dispatch_get_main_queue(), ^{//update UI code});

【讨论】:

  • @XhackerLiu 异步
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2012-01-31
  • 2015-06-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-06-07
  • 1970-01-01
相关资源
最近更新 更多