-1

私はこのタイプの質問が以前にSOでここで尋ねられたことを知っています、そして私はそれらのほとんどすべてを試しましたが、役に立ちませんでした。UITableViewから行を削除しようとしています。これが私のコードです。

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (editingStyle == UITableViewCellEditingStyleDelete) {
        //calls to a method that deletes the row from the backend SQLite database
        [self deleteCompany:indexPath.row];

        //theCompanies is a NSMutableArray. When the app starts, it retrieves the data and display it in the UITableView
        [theCompanies removeObjectAtIndex:indexPath.row];

        //Below line is where the error occurs. 
        [self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath]
                         withRowAnimation:YES
              UITableViewRowAnimationFade:UITableViewRowAnimationFade];
    }   
    else if (editingStyle == UITableViewCellEditingStyleInsert) {

    }   
}

アプリをビルドすると、次のコンパイラエラーが発生します。

'UITableView'の表示された@interfaceはセレクターを宣言しません...

次に何をすべきかわからない。どんな助けでもいただければ幸いです。

ありがとうございました。

4

2 に答える 2

2

方法はこんな感じ

- (void)deleteRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation

2つの引数を使用して、ここを参照してくださいApple UITableView Document

しかし、あなたは3つの引数のisとwithRowAnimationをBOOLとして使用しましたが、BOOLではありません。

次のようなものを試してください。

[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
于 2013-01-09T12:06:42.367 に答える
2

この行を変更します。

[self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath]
                         withRowAnimation:YES
              UITableViewRowAnimationFade:UITableViewRowAnimationFade];

[self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath]
                         withRowAnimation:UITableViewRowAnimationFade];
于 2013-01-09T12:08:44.193 に答える