【发布时间】:2016-06-24 08:38:56
【问题描述】:
我有包含 del 按钮并添加的 collectionview
cell.coupon_add.tag = indexPath.row
cell.coupon_add?.layer.setValue(id, forKey: "coupon_id")
cell.coupon_add?.layer.setValue(uID, forKey: "user_id")
cell.coupon_add?.addTarget(self, action: #selector(ViewController.addItem(_:)), forControlEvents: UIControlEvents.TouchUpInside)
func addItem(sender:UIButton) {
let point : CGPoint = sender.convertPoint(CGPointZero, toView:collectionview)
let indexPath = collectionview!.indexPathForItemAtPoint(point)
let cell = collectionview.dequeueReusableCellWithReuseIdentifier("listcell", forIndexPath: indexPath!) as! ListCell
let coupon_id : String = (sender.layer.valueForKey("coupon_id")) as! String
let user_id : String = (sender.layer.valueForKey("user_id")) as! String
if user_id == "empty" {
self.login()
}else{
print("adding item**",indexPath)
cell.coupon_add.hidden = true
cell.coupon_del.hidden = true
let buttonRow = sender.tag
print(buttonRow)
}
}
我想在触发时隐藏添加按钮。我只是得到了 indexPath 的值,但我不知道如何在不刷新 collectionview 的情况下隐藏它
【问题讨论】:
-
@funi1234 我试试你的代码它不起作用
-
也许this 回答会有所帮助
-
@tahavath let indexArray = NSArray(object: indexPath!) self.collectionview.reloadItemsAtIndexPaths(indexArray as! [NSIndexPath]) 我这样尝试我遇到崩溃可以检查原因
-
错误是什么?
-
现在可以了,我没有收到错误但什么也没发生按钮没有隐藏@tahavath
标签: ios swift swift2 uicollectionview