我的ViewController中有一个UIRefreshControl和一个方法refreshView来处理“拉到刷新”事件.实际拉动时效果很好,但是当我在代码中调用[refresh beginRefreshing]时,它只显示刷新动画但不调用refreshView方法.
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.
我认为它不是用来启动刷新操作,而只是用于更新当前刷新的刷新控制状态,它将使刷新控制旋转.目的是避免用户拉出表视图并在仍然刷新时再次触发刷新操作.