Checkmark不会在iOS7上的TableViewCell中显示 [英] Checkmark won't show in TableViewCell on iOS7
问题描述
我现在正处理一个奇怪的问题。我的应用程序部署目标设置为iOS6,所以我想支持iOS6和iOS7。
I'm working on a weird issue right now. My Apps Deployment Target is set to iOS6, so I want to support both iOS6 and iOS7.
我只有一个简单的UITableView,用户可以在其中选择首选通知声音。
I just have a simple UITableView, in which the user can select the preferred notification sound.
的代码 - (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)。
The problem is that an iOS7 iPhone won't show the checkmark as expected. Running the same code on an iOS6 iPhone works as expected. I tried to insert [cell setTintColor:[UIColor redColor]];
but without any luck. Even if I remove all AccessoryType related code and add the checkmark in my storyboard nothing appears. See screenshots below (first is iOS6 and second is iOS5).
有没有人有想法?或者它是iOS7中的错误?
Does anyone have an idea ? Or is it a bug in iOS7 ?
提前致谢!
编辑:
即使我创建了一个新的简单UITableViewController,只有5个单元,Accessory设置为UITableViewAccessoryTypeCheckmark,Checkmarks也不会出现在iOS7上。
Even if I make a new simple UITableViewController, with just 5 cells with the Accessory set to UITableViewAccessoryTypeCheckmark, the Checkmarks won't appear on iOS7.
推荐答案
我有一个类似的问题,我解决了这个问题,改变了uitableview的色调颜色
I had a similar problem and I solved this issues changing the tint color of the uitableview
我通过InterfaceBuilder将uint的tintcolot改为默认颜色
I changed the tintcolot of uitable by InterfaceBuilder to Default color
或
tableView.tintColor = [UIColor blackColor];
这篇关于Checkmark不会在iOS7上的TableViewCell中显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!