ここではBOOl
の値を使用しています。TableView
の各セクションの値です。最初のセクションには静的なデータがあり、2番目のセクションには動的なデータがあります。セクションの各行にブール値が必要です。しかし、私はそうすることができません。第2セクションには動的なデータがあるからです。私はどのように静的か動的かの各セルをブール値として設定することができますか?すべてのTableViewCellにBOOL値を設定します
ここに私のコードです。どのように私はこれを実装することができ、上記のコードで
BOOL zero,one,dynamic
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:
(NSInteger)section{
if (section == 0) {
return 2;
}if (section == 1) {
return [myData count];
}
return nil;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath: (NSIndexPath *)indexPath{
if (indexPath.row == 0 && indexPath.section == 0) {
[tableView cellForRowAtIndexPath:indexPath].accessoryType = UITableViewCellAccessoryCheckmark;
cell.accessoryView.hidden = NO;
zero = true;
}if (indexPath.row == 1 && indexPath.section == 0) {
one = true;
[tableView cellForRowAtIndexPath:indexPath].accessoryType = UITableViewCellAccessoryCheckmark;
cell.accessoryView.hidden = NO;
}
if (indexPath.section == 2) {
cell = [tableView cellForRowAtIndexPath:indexPath];
dynamic = true;
}
}
は、私はあなたが私を提案してくださいすることができ、セクション2に
BOOL
値各行をしたいですか?
ありがとうございました。
セル内の状態を反映するブール値プロパティをモデルに作成します。モデルの値を変更し、テーブルビューをリロードします。基本的にはビューを操作しないでください。 – vadian