Ios6 选中标记赢得';在iOS7上的TableViewCell中不显示

Ios6 选中标记赢得';在iOS7上的TableViewCell中不显示,ios6,uitableview,ios7,Ios6,Uitableview,Ios7,我现在正在处理一个奇怪的问题。我的应用程序部署目标设置为iOS6,因此我希望同时支持iOS6和iOS7 我只有一个简单的UITableView,用户可以在其中选择首选的通知声音 -(UITableViewCell*)tableView:(UITableView*)tableView cellforrowatinexpath:(nsindepath*)indepath的代码是: -(UITableViewCell*)tableView:(UITableView*)tableView cellFor

我现在正在处理一个奇怪的问题。我的应用程序部署目标设置为iOS6,因此我希望同时支持iOS6和iOS7

我只有一个简单的UITableView,用户可以在其中选择首选的通知声音

-(UITableViewCell*)tableView:(UITableView*)tableView cellforrowatinexpath:(nsindepath*)indepath
的代码是:

-(UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath
{
静态NSString*CellIdentifier=@“CheckmarkCell”;
UITableViewCell*单元格=[tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
[单元格设置颜色:[UIColor redColor]];
if(indexPath.section==0){
cell.textlab.text=[\u availableSounds objectAtIndex:indexPath.row];
if(indexath.row==\u checkedSoundIndexath.row){
cell.accessoryType=UITableViewCellAccessoryCheckmark;
}
}
否则{
//不相关,另一个设置单元格
cell.accessoryType=UITableViewCellAccessoryNone;
cell.selectionStyle=UITableViewCellSelectionStyleNone;
}
返回单元;
}
我的
-(void)tableView:(UITableView*)tableView didSelectRowAtIndexPath:(nsindepath*)indepath
如下所示:

-(void)tableView:(UITableView*)tableView didSelectRowAtIndexPath:(nsindepath*)indepath
{
if(indexPath.section!=0){
返回;
}
[self.tableView取消rowatinexpath:indexath:YES];
[[self.tableView cellForRowAtIndexPath:indexPath]setAccessoryType:UITableViewCellAccessoryCheckmark];
if(_checkedSoundIndexPath!=indexPath){
[[self.tableView cellForRowAtIndexPath:[u checkedSoundIndexPath]setAccessoryType:UITableViewCellAccessoryNone];
}
_checkedSoundIndexPath=indexPath;
}
问题在于iOS7 iPhone不会像预期的那样显示复选标记。在ios6iphone上运行相同的代码可以正常工作。我尝试插入
[cell setTintColor:[UIColor redColor]]但是没有任何运气。即使我删除了所有与AccessoryType相关的代码并在情节提要中添加了复选标记,也不会显示任何内容。请参阅下面的屏幕截图(第一个是iOS6,第二个是iOS5)

有人有主意吗?或者它是iOS7中的一个bug

提前谢谢

编辑:

即使我制作了一个新的简单的UITableViewController,只有5个单元格,附件设置为UITableViewAccessoryTypeCheckmark,这些复选标记也不会出现在iOS7上


否,iOS 7中的UITableViewCellAccessoryCheckmark没有问题,请确保为其实现了正确的逻辑

In my application it working perfect,check it 
//将其放入.h文件可变arSelectedRows;
-(UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath
{
静态NSString*CellIdentifier=@“Cell”;
UITableViewCell*单元格=[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
如果(单元格==nil){
cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault重用标识符:CellIdentifier];
}
[单元格设置选择样式:UITableViewCellSelectionStyleGray];
//你想在这里做什么
if([arSelectedRows containsObject:indexPath]){
cell.accessoryType=UITableViewCellAccessoryCheckmark;
}
否则{
cell.accessoryType=UITableViewCellAccessoryNone;
}
返回单元;
}
#pragma标记-表视图委托
-(void)tableView:(UITableView*)tableView未选择RowatineXpath:(NSIndexPath*)indexPath
{
UITableViewCell*单元格=[tableView cellForRowAtIndexPath:indexPath];
if(cell.accessoryType==UITableViewCellAccessoryNone){
cell.accessoryType=UITableViewCellAccessoryCheckmark;
[arSelectedRows addObject:indexPath];
}
否则{
cell.accessoryType=UITableViewCellAccessoryNone;
[arSelectedRows removeObject:indexPath];
}
NSLog(@“id在这里:%@”,arselectedds);
[tableView取消行索引路径:indexPath动画:是];
}

可能会有帮助。

我遇到了类似的问题,我通过更改uitableview的色调解决了这个问题

我将InterfaceBuilder的uitable颜色更改为默认颜色


我认为问题在于您的checksoundIndexpath,请检查它是否有正确的indexpath,或者首先使用硬编码的indexpath进行检查

您没有初始化checksoundindxpath


我还注意到您没有将选定的行indexpath分配给_checksoundindexath,只是检查两个indexpath(当前indexpath和_checksoundindexath)是否相等,但如果它们不同,则应将选定的indexpath分配给_checksoundindexath。

我宁愿重新加载tableview(最好只有受影响的行-使用
reloadrowsatinexpaths
)在
didSelectRowAtIndexPath:
方法中设置适当的数据后

-(void)tableView:(UITableView*)tableView didSelectRowAtIndexPath:(nsindepath*)indepath{
//其他逻辑。。
[tableView取消RowAtIndexPath:indexPath动画:否];//是否要寻找替代方法以避免此刷新??
NSMutableArray*reloadArray=[NSMutableArray阵列容量:2];
[reloadArray addObject:indexPath];
[reloadArray addObject:_checkedSoundIndexPath];
self.checkedSoundIndexPath=indexPath;//应在重新加载之前设置此选项
[tableView重新加载RowSatindExpaths:reloadArray with RowAnimation:UITableViewRowAnimationAutomatic];
}
最重要的是,在cellForRowAtIndexPath中添加以下行:方法-

-(UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath{
//本节的所有其他代码如下
tableView.tintColor =  [UIColor blackColor];
 - (void)layoutSubviews
{
    [super layoutSubviews];
    //...custom layout here
}