-2

オブジェクトのセットをラベルの下に保存するプログラムを作成しました。ラベルは後で表示および変更できます。そのために次のコードを作成しました(チェックマークを追加する部分のみを含む):

- (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

cell.selectionStyle = UITableViewCellSelectionStyleNone; //To avoid the blue selection
//necessary codes to populate the table here
[tableView cellForRowAtIndexPath:indexPath].accessoryType = UITableViewCellAccessoryCheckmark;
return cell;
}

しかし、テーブルにはチェックマークさえ表示されていません。はい、コメントをオフにして再試行しましたがcell.selectionStyle = UITableViewCellSelectionStyleNone;、まだ役に立ちません。既に作成されたチェックマークをオフにするためのコードを他の場所に書いていません。

4

3 に答える 3

3

[tableView cellForRowAtIndexPath:indexPath].accessoryTypeこのメソッドでセル自体を取得しているので、 なぜこのようにアクセサリの種類を設定するのですか

- (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
     { 
        cell.selectionStyle = UITableViewCellSelectionStyleNone; //To avoid the blue selection
       //necessary codes to populate the table here
       cell.accessoryType = UITableViewCellAccessoryCheckmark; //Do like this   
       return cell;
}


于 2013-07-22T10:06:19.520 に答える
1

交換

[tableView cellForRowAtIndexPath:indexPath].accessoryType = UITableViewCellAccessoryCheckmark;

cell.accessoryType = UITableViewCellAccessoryCheckmark;
于 2013-07-22T09:57:40.283 に答える
1

チェックマークを表示するには

cell.accessoryType = UITableViewCellAccessoryCheckmark;
于 2013-07-22T12:39:26.140 に答える