collectionViewCell按钮点击无响应

之前刚在storyboard中创建出cell的时候点击都有反应,但是之后填充数据之后整个cell就像被盖住了一样...没有反应了..

图片描述图片描述图片描述

override func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
    let cell = collectionView.dequeueReusableCellWithReuseIdentifier("Cell", forIndexPath: indexPath) as ReadingCard

    let point = currentPoints![indexPath.item] as Point
    cell.setTitle(point.title)
    cell.setContent(point.content)

    var imageData = self.imageCache.objectForKey(NSString(format: "%d", indexPath.item)) as? NSData
    if let imageData_ = imageData{
        cell.setImage(UIImage(data: imageData_))
    }

    return cell
}

然后cell的子类代码:

class ReadingCard: UICollectionViewCell {

@IBOutlet weak var title: UILabel!
@IBOutlet weak var imageView: UIImageView!
@IBOutlet weak var content: UITextView!
@IBAction func collectButtonClicked() {
    println("collectButtonClicked")
}

@IBAction func commentButtonClicked(sender: AnyObject) {
    println("commentButtonClicked")
}

@IBAction func naviButtonClicked(sender: AnyObject) {
    println("naviButtonClicked")
}
func setTitle(title:NSString?){
    if let title_ = title{
        self.title.text = title_
    }
}
func setContent(content:NSString?){
    if let content_ = content{
        self.content.text = content_
    }
}
func setImage(image:UIImage?){
    self.imageView.backgroundColor = UIColor.grayColor()
    if let image_ = image{
        self.imageView.image = image_
    }
    else{
    }
    imageView.contentMode = UIViewContentMode.ScaleAspectFit
}
}

是哪里出了问题呢...

阅读 13.1k
1 个回答
✓ 已被采纳新手上路,请多包涵

发现不能把那些组件单独用一个view来当作容器,这样会导致无法交互。把多余的view去除就好了。

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题
宣传栏