子視圖在我ViewController
,我有一個變量:取出內細胞
var shareButtonTapped = false
我想,當我點擊shareButton
的navigationBar
,它會顯示shareButton所有的細胞,除了電池,其indexPath .row == 0,
這裏是shareButton
動作:
@IBAction func shareButtonTapped(sender: AnyObject) {
shareButtonTapped = !shareButtonTapped
collectionView.reloadData()
}
這裏是CollectionViewDataSource方法:
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCellWithReuseIdentifier("cell", forIndexPath: indexPath) as! GiftCollectionViewCell
if shareButtonTapped {
cell.gift = gifts[indexPath.row]
let shareButton = FBSDKShareButton(frame: CGRect(x: 0, y: 0, width: 80, height: 30))
shareButton.tag = 1
let photo = FBSDKSharePhoto()
photo.image = gifts[indexPath.row].image
photo.userGenerated = true
let content = FBSDKSharePhotoContent()
content.photos = [photo]
content.contentURL = NSURL(string: "http://www.fantageek.com")
shareButton.shareContent = content
cell.contentView.addSubview(shareButton)
return cell
} else {
cell.gift = gifts[indexPath.row]
return cell
}
}
它的工作:
但我想再次點擊此shareButton
上NavigationBar
,所有的shareButton
內的每個細胞就會消失。這個怎麼做?
任何幫助,將不勝感激。謝謝。
感謝您幫助。 – Khuong