首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在桌面视图中快速显示Checkmark?

如何在桌面视图中快速显示Checkmark?
EN

Stack Overflow用户
提问于 2016-11-24 09:18:41
回答 4查看 2.6K关注 0票数 1

在为某些数组值选择之前,我必须先显示复选标记,然后必须显示数组值1的复选标记和0的无复选标记。如何做that..check下面的代码:

代码语言:javascript
复制
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell
{

    let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath)
    cell.textLabel?.text = AllItems[indexPath.row] as? String
    for dict1  in selectedItems
    {
         if Intvalues == dict1 as? NSObject  {
           // I have to show CheckMark
}
          else if ZeroIntvalues == dict1 as? NSObject
         {
            // I don’t need to show CheckMark



        }
    }
    cell.textLabel?.textColor = UIColor.whiteColor()
    return cell
}
EN

回答 4

Stack Overflow用户

回答已采纳

发布于 2016-11-24 09:27:09

“因为原因,”Paulw11 11说,“您的代码是错误的。每个tableViewCell都会显示复选标记,因为for循环的最后一个对象总是1

代码语言:javascript
复制
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell
{
    let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath)
    cell.textLabel?.text = AllItems[indexPath.row] as? String
        if Intvalues == AllItems[indexPath.row] as? Int  {
           // I have to show CheckMark
          cell.accessoryType = .Checkmark
         } else {
          cell.accessoryType = .None
         }
    cell.textLabel?.textColor = UIColor.whiteColor()
    return cell
}
票数 3
EN

Stack Overflow用户

发布于 2016-11-24 09:20:46

Tableview单元格有附件类型,在tableviewCellForRowAtIndexPath中使用此类型

代码语言:javascript
复制
cell.accessoryType = UITableViewCellAccessoryCheckmark;
票数 1
EN

Stack Overflow用户

发布于 2016-11-24 09:21:16

您在下面显示支票标记。

代码语言:javascript
复制
  cell.accessoryType = .None
if Intvalues == dict1 as? NSObject  {
     // I have to show CheckMark
     cell.accessoryType = .Checkmark
}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/40782238

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档