以前、UITableViewCellの背景色を変更するというエントリーを書きましたが、その後、プログラムをしていたら、これだと不具合が発生することがわかりました。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ cell.contentView.backgroundColor = [UIColor redColor]; }上のプログラムだと、accessoryTypeプロパティーで値を設定した場合、contentViewで設定した背景が反映されないという不具合がありました。
stackoverflowのCell background and accessoryによると、下のように、backgroundViewで設定すれば問題ないようです。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ cell.backgroundView.backgroundColor = [UIColor redColor]; }これから実装するときは、気をつけないとな。
0 コメント:
コメントを投稿