集合标题视图自定义单元格中的UIButton操作

时间:2016-11-14 15:33:32

标签: ios swift uibutton uicollectionview uicollectionviewcell

我在IB创建的标题单元格中有一个按钮。我添加动作,但我无法触发。这段代码;

 func collectionView( _ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView {

    switch kind {

    case UICollectionElementKindSectionHeader:

        let cell = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "sectionHeader", for: indexPath) as! ProfilePhotoHeaderCell
        cell.lblFavCount.text = user.favdCount
        let countFoto = ((user.photos?.count)!)
        cell.lblFotoCount.text = countFoto.description
        cell.btnAddPhotos.isUserInteractionEnabled = true
        cell.btnAddPhotos?.addTarget(self, action: #selector(ProfileController.myAction(sender:)), for: .touchUpInside)  // add selector
        return cell
    case IOStickyHeaderParallaxHeader:
        let headerView = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "headerCell1", for: indexPath) as! ProfileParallaxHeaderCell

        return headerView
    default:
        assert(false, "Unexpected element kind")

    }


       }

0 个答案:

没有答案
相关问题