微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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.jb51.cc/iOS/334907.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐