ios – UIRefreshControl在prorgammatically调用时无法正常工作

前端之家收集整理的这篇文章主要介绍了ios – UIRefreshControl在prorgammatically调用时无法正常工作前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我的ViewController中有一个UIRefreshControl和一个方法refreshView来处理“拉到刷新”事件.实际拉动时效果很好,但是当我在代码调用[refresh beginRefreshing]时,它只显示刷新动画但不调用refreshView方法.

这是在viewDidload中初始化刷新控件代码

UIRefreshControl *refresh = [[UIRefreshControl alloc] init];
refresh.attributedTitle = [[NSAttributedString alloc] initWithString:@"Pull to Refresh"];
[refresh addTarget:self
            action:@selector(refreshView:)
  forControlEvents:UIControlEventValueChanged];
self.refreshControl = refresh;

解决方法

根据我对文档的理解: http://developer.apple.com/library/ios/#documentation/uikit/reference/UIRefreshControl_class/Reference/Reference.html

Tells the control that a refresh operation was started
programmatically. … Call this method when an external event
source triggers a programmatic refresh of your table.

我认为它不是用来启动刷新操作,而只是用于更新当前刷新的刷新控制状态,它将使刷新控制旋转.目的是避免用户拉出表视图并在仍然刷新时再次触发刷新操作.

所以你应该自己调用refreshView:方法.

原文链接:https://www.f2er.com/iOS/334907.html

猜你在找的iOS相关文章