按下行时不会调用didSelectRowAtIndexPath

时间:2017-08-13 09:48:07

标签: ios swift uitableview

我在表格视图中有5个自定义单元格,但didSelectRowAtIndexPath不适用于一个单元格。我在代码中为该单元格的索引添加了行的单元格。

let cell : FileSentCell = chatTableView.dequeueReusableCell(withIdentifier: "fileSend") as! FileSentCell
                let fileUrl = self.getImageURL(forFileName: fileNameString!)
                if(fileUrl == nil){
                    cell.downloadStatusIndicator.image = #imageLiteral(resourceName: "fileDownloadWhite")
                }else{
                    cell.downloadStatusIndicator.image = #imageLiteral(resourceName: "downloadedWhite")
                }
                cell.downloadStatusIndicator.isHidden = false
                cell.downloadingIndicator.alpha = 0.0
                cell.sendFileView.layer.cornerRadius = 10
                cell.name.text = groupMsg.senderDisplayName
                cell.message.text = groupMsg.message
                cell.time.text =  groupMsg.dateSent!
                cell.fileStatus.text = groupMsg.status
                cell.fileIcon.image = returnImage(fileName:groupMsg.message!)
                cell.sendFileView.tag  = indexPath.row
                cell.sendFileView.addGestureRecognizer(longPressGesture)
                cell.sendFileView.isUserInteractionEnabled = true

                return cell

我让UITableview有一个选择。并且除了这一个单元格之外,所有其他重用单元都会调用didSelectRowAtIndexPath 有没有理由或者我应该在cellforat行中改变一些东西

我的 FileSentCell 类是

import UIKit
import QuartzCore

class FileSentCell: UITableViewCell {

@IBOutlet var sendFileView : UIView!
@IBOutlet var message : ChatLabel!
@IBOutlet var time : UILabel!
@IBOutlet var fileStatus : UILabel!
@IBOutlet var fileIcon : UIImageView!
@IBOutlet var downloadStatusIndicator : UIImageView!
@IBOutlet var downloadingIndicator: UIActivityIndicatorView!

override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
    super.init(style: style, reuseIdentifier: reuseIdentifier)

}

required init(coder aDecoder: NSCoder) {
    //fatalError("init(coder:) has not been implemented")
    super.init(coder: aDecoder)!
}

override func awakeFromNib() {
    super.awakeFromNib()
}

override func setSelected(_ selected: Bool, animated: Bool) {
    super.setSelected(selected, animated: animated)
}

override func layoutSubviews() {
    super.layoutSubviews()
}
}

还有一件事是,如果我在内容视图中减少UIView的宽度并单击未显示UIView的行didSelectRow正在调用,那么didSelectRow仅在它被调用时才被调用点击了内容视图中的UIView

先谢谢。

1 个答案:

答案 0 :(得分:0)

集:

h1