[英]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.