在自定义表格视图单元格中使用dequeueReusableCell泄漏内存

时间:2017-02-22 12:36:49

标签: swift3 tableview

我在表视图单元格中有dequeueReusableCell的问题每次我在tableView中滚动我得到内存泄漏当我在Xcode中使用工具工具它告诉我这个函数的泄漏我怎么能解决这个问题请帮帮我解决这个问题。

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {


        let cell = tableView.dequeueReusableCell(withIdentifier: "MovieCell") as! MovieTableViewCell

        // her for the button delete in cell
        // add target
        cell.changeFolderNameButton.tag = indexPath.row
        cell.changeFolderNameButton.addTarget(self, action: #selector(self.changeFolderName(sender:)), for: .touchUpInside)
        /////////////
        cell.imageViewCheckMark.isHidden = true
        cell.imageViewSelect.isHidden = true

        let getFile = ARRAYOFFOLDERS[indexPath.row]

        // for display the URL for each folder in the documents
        cell.URLFolderLabel.text = ARRAYOFFOLDERS[indexPath.row].absoluteString

        if getFile.pathExtension == "" {
            cell.imageViewCell.image = UIImage(named: "folder")
            cell.folderNameLabel.text = getFile.lastPathComponent
        }else{
            cell.imageViewCell.image = UIImage(named: "movie")
            cell.folderNameLabel.text = getFile.lastPathComponent
        }


        if ARRAY_HOLD_ALL_CELL_WITH_EMPTY_CIRCLE.count > 0 && STATUS_EDIT_BUTTON {
            // for show all the empty circle near to folder
            if ARRAY_HOLD_ALL_CELL_WITH_EMPTY_CIRCLE[indexPath.row] == indexPath.row {
                cell.imageViewSelect.isHidden = false
                cell.imageViewCheckMark.isHidden = true
            }
        }else if STATUS_EDIT_BUTTON == false && ARRAY_HOLD_ALL_CELL_WITH_EMPTY_CIRCLE.count > 0 {
            if ARRAY_HOLD_ALL_CELL_WITH_EMPTY_CIRCLE[indexPath.row] == indexPath.row {
                cell.imageViewSelect.isHidden = true
                cell.imageViewCheckMark.isHidden = true
            }
        }

        // for show the checkmark on the cell which user select it
        if STATUS_EDIT_BUTTON && DICTIONARY_OF_SELECT_FILE.count > 0 {
            if DICTIONARY_OF_SELECT_FILE[indexPath.row] == indexPath.row {
                cell.imageViewCheckMark.isHidden = false
                cell.imageViewSelect.isHidden = true
            }
        }else if STATUS_EDIT_BUTTON == false && DICTIONARY_OF_SELECT_FILE.count > 0 {
            if DICTIONARY_OF_SELECT_FILE[indexPath.row] == indexPath.row {
                cell.imageViewSelect.isHidden = true
                cell.imageViewCheckMark.isHidden = true
            }
        }
        ////////////////

        return cell

    }

非常感谢

0 个答案:

没有答案