Uitableview 执行JSON POST时是否重新加载TableView?
我在每个UITableViewCell中都有一个按钮。我要执行刷新Rowatinex的操作。每当点击按钮时。执行AFN网络的POST请求方法。我在ViewdidLoad方法中获得了请求方法 在UITableViewCell中单击按钮时,如何在Basecamp应用程序加载动画时更新数据 尝试以下操作:Uitableview 执行JSON POST时是否重新加载TableView?,uitableview,afnetworking,Uitableview,Afnetworking,我在每个UITableViewCell中都有一个按钮。我要执行刷新Rowatinex的操作。每当点击按钮时。执行AFN网络的POST请求方法。我在ViewdidLoad方法中获得了请求方法 在UITableViewCell中单击按钮时,如何在Basecamp应用程序加载动画时更新数据 尝试以下操作: NSMutableArray *cellIsRefreshed = [NSMutableArray alloc]initWithCapacity:yourDataArray]; fo
NSMutableArray *cellIsRefreshed = [NSMutableArray alloc]initWithCapacity:yourDataArray];
for(int i=0; i<[yourDataArray count]; i++)
{
cellIsRefreshed[i] = @"0";
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
TableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CELL_Identifier forIndexPath:indexPath];
if (cell == nil) {
cell = [[TableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CELL_Identifier];
}
[cell.button addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchDown];
if([cellIsRefreshed[indexPath.row] integerValue] ==1)
{
[cell.button setHidden:YES];
[cell.doneImage setHidden: NO];
}
else
{
[cell.button setHidden:NO];
[cell.doneImage setHidden: YES];
}
return cell;
}
- (void)buttonAction :(UIButton *)sender
{
UIButton *button = (UIButton *)sender;
CGPoint pointInSuperview = [button.superview convertPoint:button.center toView:self.tableView];
NSIndexPath *indexPath = [self.tableView indexPathForRowAtPoint:pointInSuperview];
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
NSDictionary *parameters = @{@"foo": @"bar"};
[manager POST:@"http://example.com/resources.json" parameters:parameters success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"JSON: %@", responseObject);
cellIsRefreshed[indexPath.row] = @"1";
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Error: %@", error);
}];
[tableView reloadData];
}
NSMutableArray*cellIsRefreshed=[NSMutableArray alloc]initWithCapacity:yourDataArray];
对于(int i=0;iI对于'GET''POST''请求没有问题),我无法显示对按钮选择的确认,例如Basecamp应用程序,并且数据未刷新。您是否尝试过[tableview reloadData];POST Completed后您的问题有点模糊,您是否只想更新数据源更新后按下的单元格按钮?