简体   繁体   English

如何在iOS中进行肥皂请求后刷新tableview

[英]how to refresh tableview after soap request in iOS

i am retrieving data from core data and displaying it on tableview,i have another viewController which shows details of selected row from the tableview.from that viewController i am sending soap request,what i want to do is after sending request i want that selected row should be deleted from the tableview.i don't know how to do this.sorry if i am not making any sense,any help is welcomed. 我正在从核心数据中检索数据并将其显示在tableview上,我还有另一个viewController,它显示了tableview中所选行的详细信息。应该从tableview中删除。我不知道该怎么做。抱歉,如果我没有任何意义,欢迎任何帮助。

my code for tableview controller 我的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;

} }

pragma tableview delegates pragma tableview代表

-(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]

From the Documentation: 从文档中:

Declaration OBJECTIVE-C 声明目标C

  - (void)reloadData

Discussion 讨论区

Call this method to reload all the data that is used to construct the table, including cells, section headers and footers, index arrays, and so on. 调用此方法以重新加载用于构造表的所有数据,包括单元格,节的页眉和页脚,索引数组等。 For efficiency, the table view redisplays only those rows that are visible. 为了提高效率,表视图仅重新显示那些可见的行。 It adjusts offsets if the table shrinks as a result of the reload. 如果表由于重新加载而缩小,则会调整偏移量。 The table view's delegate or data source calls this method when it wants the table view to completely reload its data. 当表视图的委托或数据源希望表视图完全重新加载其数据时,将调用此方法。 It should not be called in the methods that insert or delete rows, especially within an animation block implemented with calls to beginUpdates and endUpdates. 不应在插入或删除行的方法中调用它,尤其是在通过调用beginUpdates和endUpdates实现的动画块中。

You can call [self.tableView reloadData] to refresh your table view. 您可以调用[self.tableView reloadData]刷新表视图。

If you want to do this on main thread: 如果要在主线程上执行此操作:

 dispatch_async(dispatch_get_main_queue(), ^{ [self.tableView reloadData]; });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM