应用中用到UIRefreshControl
。
遇到一些问题,请大神解答。
- (void)viewDidLoad
{
[super viewDidLoad];
self.searchDisplayController.delegate = self;
UIRefreshControl *refreshControl = [[UIRefreshControl alloc] init];
[refreshControl addTarget:self action:@selector(refresh:) forControlEvents:UIControlEventValueChanged];
[self.rearTableView addSubview:refreshControl];
}
- (void)refresh:(UIRefreshControl *)refreshControl {
[refreshControl beginRefreshing];
[NSTimer scheduledTimerWithTimeInterval:2.0 target:self selector:@selector(endRefresh:) userInfo:nil repeats:NO];
}
- (void)endRefresh:(UIRefreshControl *)refresh
{
[refresh endRefreshing];
}
拖拽tableView会初始化计时器,但是提前2秒。然后应用就崩溃了:*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFTimer endRefreshing]: unrecognized selector sent to instance 0x9c093c0'