Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-cloud-platform/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 删除行后,无法从NSObject文件重新加载UITableView数据_Ios_Objective C_Uitableview_Nsmutablearray_Nsobject - Fatal编程技术网

Ios 删除行后,无法从NSObject文件重新加载UITableView数据

Ios 删除行后,无法从NSObject文件重新加载UITableView数据,ios,objective-c,uitableview,nsmutablearray,nsobject,Ios,Objective C,Uitableview,Nsmutablearray,Nsobject,按delete按钮时,它会从WebServer数据源中删除选定对象,但无法重新加载TableView 这里是我的代码,请建议如何完成这一点或让我 让我知道我哪里做错了 删除按钮功能 - (IBAction)delButton: (UIButton*)button event:(UIEvent*)event { UIButton *delButton = button; NSLog(@"FaceBook Button is sharing %li row's Image", (lo

按delete按钮时,它会从WebServer数据源中删除选定对象,但无法重新加载TableView

这里是我的代码,请建议如何完成这一点或让我 让我知道我哪里做错了

删除按钮功能

- (IBAction)delButton: (UIButton*)button event:(UIEvent*)event
{
    UIButton *delButton = button;
    NSLog(@"FaceBook Button is sharing %li row's Image", (long)delButton.tag);

    NSIndexPath* indexPath = [self.tableView indexPathForRowAtPoint:
                              [[[event touchesForView:button] anyObject]
                               locationInView:self.tableView]];

    Records *object = self.recordsArray[delButton.tag];
    NSLog(@"selected Object %@", object);
    NSString *id = object.recordsId;
    NSMutableString * postString = [NSMutableString stringWithString:kdeleteURL];
    [postString appendString:[NSString stringWithFormat:@"?%@=%@", kId, id]];
    [postString setString:[postString stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLFragmentAllowedCharacterSet]]];

    NSMutableURLRequest *request =[[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:postString]];

    [request setHTTPMethod:@"POST"];

    postConnection = [[NSURLConnection alloc] initWithRequest:request delegate:self startImmediately:YES];
    [self.recordsArray removeObjectAtIndex:indexPath.row];

            [self.tableView reloadData];


}
如果您需要更多信息,如对象文件的代码或从服务器端检索数据的数据检索代码段,请务必告诉我

NSIndexPath *index = [[NSIndexPath alloc] init];

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
   UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"myCell" forIndexPath:indexPath];

    Records * RecordsObject;

    RecordsObject = [recordsArray objectAtIndex:indexPath.row];
    cell.textLabel.text = RecordsObject.recordsMname;
    cell.detailTextLabel.text= RecordsObject.recordsImei;

    UIButton *detailButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [detailButton setImage:[UIImage imageNamed:@"edit"] forState:UIControlStateNormal];
    detailButton.frame = CGRectMake(WidthCalculation - 45, 0.0f, 50.0f, 45.0f);
    [cell addSubview:detailButton];
    [detailButton addTarget:self
                     action:@selector(detailsButton:)
           forControlEvents:UIControlEventTouchUpInside];
    [cell.contentView addSubview:detailButton];
    [detailButton setTag:indexPath.row];


    UIButton *deleteButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [deleteButton setImage:[UIImage imageNamed:@"trash"] forState:UIControlStateNormal];
    deleteButton.frame = CGRectMake(WidthCalculation - 75, 0.0f, 50.0f, 45.0f);
    deleteButton.tag = indexPath.row
    [cell addSubview:deleteButton];
    [deleteButton addTarget:self
                       action:@selector(delButton:event:)
             forControlEvents:UIControlEventTouchUpInside];
     [cell.contentView addSubview:deleteButton];



    // Configure the cell...

    return cell;
}

- (IBAction)delButton: (UIButton*)button event:(UIEvent*)event
{
    UIButton *delButton = button;
    NSLog(@"FaceBook Button is sharing %li row's Image", (long)delButton.tag);

    NSIndexPath* indexPath = [self.tableView indexPathForRowAtPoint:
                              [[[event touchesForView:button] anyObject]
                               locationInView:self.tableView]];

    Records *object = self.recordsArray[delButton.tag];
    NSLog(@"selected Object %@", object);
    NSString *id = object.recordsId;
    NSMutableString * postString = [NSMutableString stringWithString:kdeleteURL];
    [postString appendString:[NSString stringWithFormat:@"?%@=%@", kId, id]];
    [postString setString:[postString stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLFragmentAllowedCharacterSet]]];

    NSMutableURLRequest *request =[[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:postString]];

    [request setHTTPMethod:@"POST"];

    postConnection = [[NSURLConnection alloc] initWithRequest:request delegate:self startImmediately:YES];
    index = indexPath
}
若得到成功响应,则从数组中删除行和对象

-(void)serviceResponce() {
   [self.recordsArray removeObjectAtIndex:indexPath.row];
   [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject: index] withRowAnimation:UITableViewRowAnimationNone];
}
-(void)serviceResponce() {
   [self.recordsArray removeObjectAtIndex:indexPath.row];
   [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject: index] withRowAnimation:UITableViewRowAnimationNone];
}