[英]how to refresh tableview after soap request in iOS
我正在從核心數據中檢索數據並將其顯示在tableview上,我還有另一個viewController,它顯示了tableview中所選行的詳細信息。應該從tableview中刪除。我不知道該怎么做。抱歉,如果我沒有任何意義,歡迎任何幫助。
我的tableview控制器代碼
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString*cellTableIdentifier=@"CellIdentifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellTableIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellTableIdentifier];
}
self.pendingTable.bounces = YES;
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
// Configure the cell...
NSManagedObject *webDetail= [self.detailWebServce objectAtIndex:indexPath.row];
NSString*results=[[NSString alloc]initWithFormat:@"%@",[webDetail valueForKey:@"username"]];
cell.imageView.image=[UIImage imageWithData:[webDetail valueForKey:@"images"]];
NSString*date=[[NSString alloc]initWithFormat:@"%@",[webDetail valueForKey:@"currentDate"]];
[cell.detailTextLabel setText:date];
[cell.textLabel setText:results];
return cell;
}
-(void)tableView:(UITableView*)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
DetailComplaints *detailComplaints = [[UIStoryboard storyboardWithName:@"Main" bundle:nil]
instantiateViewControllerWithIdentifier:@"DetailComplaints"];
detailComplaints.tempWebData=[self.detailWebServce objectAtIndex:indexPath.row];
[self.navigationController pushViewController:detailComplaints animated:YES];
[self dismissViewControllerAnimated:NO completion:nil];
}
需要使用UITableView's
reloadData
方法重新加載tableview中的內容,但首先需要update
tablview's
datasource
數組或字典。
[YourTableViewHere reloadData]
從文檔中:
聲明目標C
- (void)reloadData
討論區
調用此方法以重新加載用於構造表的所有數據,包括單元格,節的頁眉和頁腳,索引數組等。 為了提高效率,表視圖僅重新顯示那些可見的行。 如果表由於重新加載而縮小,則會調整偏移量。 當表視圖的委托或數據源希望表視圖完全重新加載其數據時,將調用此方法。 不應在插入或刪除行的方法中調用它,尤其是在通過調用beginUpdates和endUpdates實現的動畫塊中。
您可以調用[self.tableView reloadData]
刷新表視圖。
如果要在主線程上執行此操作:
dispatch_async(dispatch_get_main_queue(), ^{ [self.tableView reloadData]; });
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.