子视图在我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