2016-03-29 17 views
0

viewForSupplementaryElementOfKind içinde bir seçim nasıl tanınır? header içindeki düğmeye bir hedef eklemeyi denedim, ancak çalışmaz. Seçim eylemi didSelectItemAtIndexPath'a mı gönderildi yoksa başka bir şey var mı? başlık bütün elemanlar bir UIStackViewUICollectionView viewForSupplementaryElementOfKind didSelect

override func collectionView(collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, atIndexPath indexPath: NSIndexPath) -> UICollectionReusableView { 

    if kind == UICollectionElementKindSectionHeader { 
     let cell = collectionView.dequeueReusableSupplementaryViewOfKind(UICollectionElementKindSectionHeader, withReuseIdentifier: "header", forIndexPath: indexPath) as! mainCell 
     let index = indexPath.section 
     cell.btnImg.af_setBackgroundImageForState(.Normal, URL: NSURL(string: "urrl")!) 
     cell.userImg.addTarget(self, action: #selector(MainController.showNextView(_:)), forControlEvents: .TouchUpInside) 
     let tap = UIGestureRecognizer(target: self, action: #selector(self.test)) 
     cell.addGestureRecognizer(tap) 
     return cell 
    } else { 

     return UICollectionReusableView() 
    } 
} 

cevap

0

içinde Sen bir UIControl veya UIGestureRecognizer kullanmanız gerektiğini doğrudur vardır. Hem örnek kodunuza eklediğiniz hem de UIGestureRecognizer düğmenizin yerine dokunmalarını tüketiyor gibi görünüyor.