私は今、奇妙な問題に取り組んでいます。My Apps Deployment Target は iOS6 に設定されているため、iOS6 と iOS7 の両方をサポートしたいと考えています。
ユーザーが好みの通知音を選択できるシンプルなUITableViewがあります。
コード- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
は次のとおりです。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"CheckmarkCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
[cell setTintColor:[UIColor redColor]];
if (indexPath.section == 0){
cell.textLabel.text = [_availableSounds objectAtIndex:indexPath.row];
if (indexPath.row == _checkedSoundIndexPath.row) {
cell.accessoryType = UITableViewCellAccessoryCheckmark;
}
}
else {
// Unrelated, another settings cell
cell.accessoryType = UITableViewCellAccessoryNone;
cell.selectionStyle = UITableViewCellSelectionStyleNone;
}
return cell;
}
私- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
は次のように見えます:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.section != 0) {
return;
}
[self.tableView deselectRowAtIndexPath:indexPath animated:YES];
[[self.tableView cellForRowAtIndexPath:indexPath] setAccessoryType:UITableViewCellAccessoryCheckmark];
if (_checkedSoundIndexPath != indexPath) {
[[self.tableView cellForRowAtIndexPath:_checkedSoundIndexPath] setAccessoryType:UITableViewCellAccessoryNone];
}
_checkedSoundIndexPath = indexPath;
}
問題は、iOS7 の iPhone では期待どおりにチェックマークが表示されないことです。iOS6 iPhone で同じコードを実行すると、期待どおりに動作します。挿入しようとしまし[cell setTintColor:[UIColor redColor]];
たが、うまくいきませんでした。AccessoriesType 関連のコードをすべて削除して、ストーリーボードにチェックマークを追加しても、何も表示されません。以下のスクリーンショットを参照してください (1 番目は iOS6、2 番目は iOS5 です)。
誰にもアイデアはありますか?それともiOS7のバグですか?
前もって感謝します !
編集:
UITableViewAccessoryTypeCheckmark に設定されたアクセサリを持つ 5 つのセルだけで、新しい単純な UITableViewController を作成しても、iOS7 ではチェックマークが表示されません。