我正在处理一个奇怪的问题。我的Apps部署目标设置为iOS6,所以我想同时支持iOS6和iOS7。复选标记不会显示在iOS7上的TableViewCell中
我只是有一个简单的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中的错误?
在此先感谢!
编辑:
即使我提出一个新的简单的UITableViewController,只有5个细胞与附件设置为UITableViewAccessoryTypeCheckmark,复选标记不会出现在iOS7。
另一个说明。 UITableViewCellAccessoryCheckmark和UITableViewCellAccessoryDisclosureIndicator不会出现在我的应用程序的任何地方。 UITableViewCellAccessoryDetailDisclosureButton和UITableViewCellAccessoryDetailButton按预期工作。 – audience
同样的问题在这里... – giuseppe
太高兴了,我不是唯一面临这个问题的人。 :-) – audience