cell.accessoryType不显示

匿名少侠 2015-05-15 08:35:56
自定义一个tableview cell的xib文件;

然后使用tableview 本来想在选中显示勾的,发现根本不显示
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
cell.accessoryType = UITableViewCellAccessoryCheckmark;
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}

后来直接把这句 放这里面 还是不显示
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

NSString *cellIndetifier = @"SimpleTableCell";
SimpleTableCell *cell = (SimpleTableCell *) [tableView dequeueReusableCellWithIdentifier:cellIndetifier];
if(cell== nil)
{
NSArray *nib = [[NSBundle mainBundle]loadNibNamed:@"SimpleTableCell" owner:self options:nil];
cell = [nib objectAtIndex:0];
}
cell.nameLabel.text= [tableData objectAtIndex:indexPath.row];

cell.accessoryType = UITableViewCellAccessoryCheckmark;

return cell;
}
求懂的 指导下 谢谢啦
...全文
253 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
寒光冷剑 2016-09-18
  • 打赏
  • 举报
回复
引用 2 楼 u012605629 的回复:
[quote=引用 楼主 u012605629 的回复:] 自定义一个tableview cell的xib文件; 然后使用tableview 本来想在选中显示勾的,发现根本不显示 -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath]; cell.accessoryType = UITableViewCellAccessoryCheckmark; [tableView deselectRowAtIndexPath:indexPath animated:YES]; } 后来直接把这句 放这里面 还是不显示 -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ NSString *cellIndetifier = @"SimpleTableCell"; SimpleTableCell *cell = (SimpleTableCell *) [tableView dequeueReusableCellWithIdentifier:cellIndetifier]; if(cell== nil) { NSArray *nib = [[NSBundle mainBundle]loadNibNamed:@"SimpleTableCell" owner:self options:nil]; cell = [nib objectAtIndex:0]; } cell.nameLabel.text= [tableData objectAtIndex:indexPath.row]; cell.accessoryType = UITableViewCellAccessoryCheckmark; return cell; } 求懂的 指导下 谢谢啦
谢谢啦,差不多是这个问题,解决了[/quote] 问一下是怎么解决的呀?我也碰到这个问题,但是我没有xib,用的是代码,使用Masnory给控件加约束的。但是设置accessoryType的时候cell右边会空出一块位置,但是里面的箭头这些小图标不会显示。这是怎么回事呀,求问?
匿名少侠 2015-05-27
  • 打赏
  • 举报
回复
引用 楼主 u012605629 的回复:
自定义一个tableview cell的xib文件; 然后使用tableview 本来想在选中显示勾的,发现根本不显示 -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath]; cell.accessoryType = UITableViewCellAccessoryCheckmark; [tableView deselectRowAtIndexPath:indexPath animated:YES]; } 后来直接把这句 放这里面 还是不显示 -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ NSString *cellIndetifier = @"SimpleTableCell"; SimpleTableCell *cell = (SimpleTableCell *) [tableView dequeueReusableCellWithIdentifier:cellIndetifier]; if(cell== nil) { NSArray *nib = [[NSBundle mainBundle]loadNibNamed:@"SimpleTableCell" owner:self options:nil]; cell = [nib objectAtIndex:0]; } cell.nameLabel.text= [tableData objectAtIndex:indexPath.row]; cell.accessoryType = UITableViewCellAccessoryCheckmark; return cell; } 求懂的 指导下 谢谢啦
谢谢啦,差不多是这个问题,解决了
Bannings 2015-05-15
  • 打赏
  • 举报
回复
你是否使用了 Auto Layout? 先把 xib 中的 Auto Layout 关掉试试,如果发现没问题了,就能确定是约束的问题了

29,027

社区成员

发帖
与我相关
我的任务
社区描述
主要讨论与iOS相关的软件和技术
社区管理员
  • iOS
  • 大熊猫侯佩
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧