我能';在iTableView中看不到iOS 8中的删除按钮

我能';在iTableView中看不到iOS 8中的删除按钮,ios,objective-c,uitableview,Ios,Objective C,Uitableview,我刚刚用目标C代码编程了一个UITableView。我无法看到“删除”按钮或删除UITableviewCell ViewController.m的代码 } 请提供帮助。您需要设置一种将表格视图置于编辑模式的方法。因此,如果您有一个编辑按钮,您将在选择器中放置以下内容 - (void)editPressed:(UIButton *)editButton { [self.tableView setEditing:YES animated:YES]; } 从这里开始,您应该可以使用其他代码

我刚刚用目标C代码编程了一个UITableView。我无法看到“删除”按钮或删除UITableviewCell

ViewController.m的代码

}


请提供帮助。

您需要设置一种将表格视图置于编辑模式的方法。因此,如果您有一个编辑按钮,您将在选择器中放置以下内容

 - (void)editPressed:(UIButton *)editButton
{
    [self.tableView setEditing:YES animated:YES];
}
从这里开始,您应该可以使用其他代码进行设置。

尝试以下代码块:

- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {
        return UITableViewCellEditingStyleDelete;
}

- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
    return YES;
}

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {

   if (editingStyle == UITableViewCellEditingStyleDelete) {

        [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];

        [numbers removeObjectAtIndex:indexPath.row];
    }
}

您在哪里将表格置于编辑模式?
-(void)setEditing:(BOOL)编辑动画:(BOOL)动画{[super-setEditing:编辑动画:动画];[myTableView setEditing:编辑动画:动画];}
您缺少
编辑样式for rowatinexpath
方法。您将在其中返回
UITableViewCellEditingStyleDelete
以及如何使tableview进入编辑模式?或者您正在滑动该行以显示删除选项?
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {
return UITableViewCellEditingStyleDelete;
}


-(BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath{

    return YES;

}

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath{

    if (editingStyle == UITableViewCellEditingStyleDelete) {

        [numbers removeObjectAtIndex:indexPath.row];
        [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];

    }

}

#pragma mark - UIAlertViewDelegate methods

- (void)alertView:(UIAlertView *)alertView
clickedButtonAtIndex:(NSInteger)buttonIndex{

    if (buttonIndex == 1) {
        NSString *tmpTextField = [alertView textFieldAtIndex:0].text;

        if (!numbers) {
            numbers = [[NSMutableArray alloc] init];

            [numbers insertObject:tmpTextField atIndex:0];
            NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0];

            [self.myTableView insertRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
        }

    }

}

@end
 - (void)editPressed:(UIButton *)editButton
{
    [self.tableView setEditing:YES animated:YES];
}
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {
        return UITableViewCellEditingStyleDelete;
}

- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
    return YES;
}

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {

   if (editingStyle == UITableViewCellEditingStyleDelete) {

        [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];

        [numbers removeObjectAtIndex:indexPath.row];
    }
}