您的位置:首页 > 产品设计 > UI/UE

点击Cell的时候 出现一个 小对勾的( 确定UITableViewCell AccessoryCheckmark唯一性)

2015-12-09 16:36 393 查看
a)点击背景会变蓝色

- (UITableViewCellAccessoryType)tableView:(UITableView*)tableViewaccessoryTypeForRowWithIndexPath:(NSIndexPath
*)indexPath
{

if(indexPath.row==currentIndex){

returnUITableViewCellAccessoryCheckmark;
}

else{

returnUITableViewCellAccessoryNone;
}
}

-(void)tableView:(UITableView *)tableViewdidSelectRowAtIndexPath:(NSIndexPath
*)indexPath
{
[tableViewdeselectRowAtIndexPath:indexPath animated:NO];

if(indexPath.row==currentIndex){

return;
}
NSIndexPath
*oldIndexPath =[NSIndexPath
indexPathForRow:currentIndex

inSection:0];

UITableViewCell *newCell = [tableView
cellForRowAtIndexPath:indexPath];

if(newCell.accessoryType
== UITableViewCellAccessoryNone) {
newCell.accessoryType
=UITableViewCellAccessoryCheckmark;
newCell.textColor=[UIColor
blueColor];
}

UITableViewCell *oldCell = [tableView
cellForRowAtIndexPath:oldIndexPath];

if(oldCell.accessoryType
==UITableViewCellAccessoryCheckmark){
oldCell.accessoryType
= UITableViewCellAccessoryNone;
oldCell.textColor=[UIColor
blackColor];
}

currentIndex=indexPath.row;
}

b)点击背景不会蓝色

- (void)tableView:(UITableView
*)tableViewdidSelectRowAtIndexPath:(NSIndexPath *)indexPath{
if(seletedRow == [indexPath
row])

return;

seletedRow = [indexPath row];

[self.tableView
reloadData];
}
-(UITableViewCellAccessoryType)tableView:(UITableView*)tableViewaccessoryTypeForRowWithIndexPath:(NSIndexPath
*)indexPath
{

int row = [indexPath row];

if(row == select)

returnUITableViewCellAccessoryCheckmark;

returnUITableViewCellAccessoryNone;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: