zoukankan      html  css  js  c++  java
  • IOS问题汇总:2014-12-17 确定UITableViewCell AccessoryCheckmark唯一性+不唯一性

    确定UITableViewCell AccessoryCheckmark唯一性

    a)点击背景会变蓝色

    -(UITableViewCellAccessoryType)tableView:(UITableView *)tableView accessoryTypeForRowWithIndexPath:(NSIndexPath *)indexPath
    {
    if(indexPath.row==currentIndex){
    return UITableViewCellAccessoryCheckmark;
    }
    else{
    return UITableViewCellAccessoryNone;
    }
    }

    -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
    {
    [tableView deselectRowAtIndexPath: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 *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    if(seletedRow == [indexPath row])
    return;

    seletedRow = [indexPath row];

    [self.tableView reloadData];
    }

    -(UITableViewCellAccessoryType)tableView:(UITableView *)tableView accessoryTypeForRowWithIndexPath:(NSIndexPath *)indexPath
    {
    int row = [indexPath row];
    if(row == select)
    return UITableViewCellAccessoryCheckmark;
    return UITableViewCellAccessoryNone;
    }

    UITableViewCell AccessoryCheckmark 不唯一性

    if (cell.accessoryType == UITableViewCellAccessoryNone)
    cell.accessoryType = UITableViewCellAccessoryCheckmark;
    else
    cell.accessoryType = UITableViewCellAccessoryNone;

  • 相关阅读:
    <%!%>和<%%>的区别
    <jsp:param>传参乱码问题
    RedHat6.4 安装yum源
    J2EE中getParameter与getAttribute以及对应的EL表达式
    Ubuntu xrdp 遠端桌面連線 a
    Ubuntu SSH server 快速安裝和設定 a
    Ubuntu 12.04 快速安裝 Scrapy a
    Linux 壓縮與解壓縮指令備忘錄 a
    vim 設定快捷鍵為 [Ctrl] + [s] 存檔 a
    Linux 常用指令備忘錄 a
  • 原文地址:https://www.cnblogs.com/hanyutong/p/4425181.html
Copyright © 2011-2022 走看看