すべてではない、いくつかのセルにUITableViewCellのアクセサリーの種類を設定します
-
23-09-2019 - |
質問
私は自分のUITableViewControllerで構築されている8個の細胞を持っています。私は4日と8細胞上の開示インジケーターを表示することができますどのように知っていただきたいと思います。今、私はそれを構築しています。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
私はすべてのセルに開示インジケーターを追加しようとしている完全に承知しているものの、
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
解決
if文シンプルを使用します:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
... // do whatever
UITableViewCellAccessoryType accessoryType = UITableViewCellAccessoryNone;
if (indexPath.row == 3 || indexPath.row == 7) {
accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}
cell.accessoryType = accessoryType;
... // do whatever
}
他のヒント
あなたはindexPathはなぜだけでなく、条件付きで開示指標を適用する、知っているとき
if((indexPath.row == 3) || (indexPath.row == 7))
(indexPath.rowはもちろん0ベースのさ...第四は3であり、第八は7です。そして、あなたはあまりにもそこから出マジックナンバーを保つための#defineまたはいくつかの他の方法を使用する必要があります。)
所属していません StackOverflow