我在我的tblView中插入UIRefreshControl
,当我下拉我的表视图时,它的调用方法是cellForRowAtIndex
但是我的数组列表没有元素那么为什么它被调用了? UIRefreshControl
方法中的viewDidLoad
代码:
refreshControl = [[UIRefreshControl alloc]init];
[self.tblView addSubview:refreshControl];
[refreshControl addTarget:self action:@selector(refreshTablee) forControlEvents:UIControlEventValueChanged];
refreshTablee的代码是:
#pragma mark:refresh table
- (void)refreshTablee {
//TODO: refresh your data
[refreshControl endRefreshing];
page=1;
slot = 10;
HUD = [MBProgressHUD showHUDAddedTo:self.view animated:true];
[apiObj getAskQuestion:@{@"user_id":usr.usrid,@"owner_id":usr.owner_id ,@"page":[NSString stringWithFormat:@"%d",page]}];
[backupArr removeAllObjects];
[questionList removeAllObjects];
}
表方法是:
#pragma mark:table view delegate datasource
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return questionList.count;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
//code for returning cell
return cell;
}
-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{
if ((int)indexPath.row == (slot-2)) {
page = page+1;
slot = slot+10;
HUD = [MBProgressHUD showHUDAddedTo:self.view animated:true];
[apiObj getAskQuestion:@{@"user_id":usr.usrid,@"owner_id":usr.owner_id ,@"page":[NSString stringWithFormat:@"%d",page]}];
}
}
答案 0 :(得分:1)
根据@dreamBegin建议我在refreshTablee方法中重新加载我的表及其工作。感谢回复@ dreamBegin
#pragma mark:refresh table
- (void)refreshTablee {
//TODO: refresh your data
[refreshControl endRefreshing];
page=1;
slot = 10;
HUD = [MBProgressHUD showHUDAddedTo:self.view animated:true];
[apiObj getAskQuestion:@{@"user_id":usr.usrid,@"owner_id":usr.owner_id ,@"page":[NSString stringWithFormat:@"%d",page]}];
[backupArr removeAllObjects];
[questionList removeAllObjects];
[self.tblView reloadData];
}