【发布时间】:2015-04-10 09:05:35
【问题描述】:
我有一个 collectionView 和该 collection view 的标题。我在标题中添加了一个 UISegmentControl,现在我试图将 selectedSegmentIndex 值传递给主 collectionView,所以我试图在我的 UICollectionViewController 中为该段添加目标,但它没有返回任何内容,这是我的代码
override func collectionView(collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, atIndexPath indexPath: NSIndexPath) -> UICollectionReusableView {
let headerView = self.collectionView?.dequeueReusableSupplementaryViewOfKind(UICollectionElementKindSectionHeader, withReuseIdentifier: "header", forIndexPath: indexPath) as collectionHeaderView
headerView.controlSegment.userInteractionEnabled = true
headerView.controlSegment.addTarget(self, action: "segmentAction:", forControlEvents: UIControlEvents.TouchUpInside)
return headerView
}
func segmentAction(sender: UISegmentedControl) {
println(sender.selectedSegmentIndex)
}
【问题讨论】:
标签: swift uicollectionview uisegmentedcontrol