我的UIRefreshControl中有一个ViewController,还有一个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



我认为它不用于启动刷新操作,而只是用于更新当前正在刷新的刷新控件状态,在此状态下它将使刷新控件旋转。目的是避免用户拉动表 View 并在仍然刷新时再次触发刷新操作。

因此,您应该自己调用refreshView:方法。

关于ios - UIRefreshControl不能正常进行调用时,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/16718457/

10-09 02:19