【发布时间】:2013-10-08 13:43:03
【问题描述】:
我现在正在处理一个奇怪的问题。我的 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]];,但没有任何运气。即使我删除所有与 AccessoryType 相关的代码并在我的故事板中添加复选标记,也不会出现任何内容。请看下面的截图(第一个是iOS6,第二个是iOS5)。
有人有想法吗?还是 iOS7 的 bug?
提前致谢!
编辑:
即使我制作了一个新的简单 UITableViewController,只有 5 个将 Accessory 设置为 UITableViewAccessoryTypeCheckmark 的单元格,iOS7 上也不会出现 Checkmarks。
【问题讨论】:
-
另一个说明。 UITableViewCellAccessoryCheckmark 和 UITableViewCellAccessoryDisclosureIndicator 不会出现在我的应用程序的任何地方。 UITableViewCellAccessoryDetailDisclosureButton 和 UITableViewCellAccessoryDetailButton 按预期工作。
-
很高兴,我不是唯一一个面临这个问题的人。 :-)
-
UITableViewCell 有自定义子类吗? (你可以在 Interface Builder 中看到)
-
不,它是一个具有基本样式的 UITableViewCell。
-
我遇到了同样的问题:最初为 iOS 5 开发的项目,复选标记和披露指示器仅在 iOS 7 上不可见,尽管详细披露按钮和详细信息按钮工作正常。到目前为止,我已经尝试了建议的修复程序,但没有运气。观众,你有没有找到解决办法? (我总是可以使用附件视图来显示我自己的复选标记和披露图像,但这似乎是一个讨厌的 hack。)
标签: ios6 uitableview ios7