【发布时间】:2017-04-13 01:44:49
【问题描述】:
我正在使用火力基地。我的代码有效,但我的问题是当我按下接受按钮时,我希望从 collectionView 中删除该索引,并且我希望表在之后立即重新加载。我无法使用幻灯片删除,因为我需要它来执行其他功能。
这是在我的单元格中,这就是为什么我没有使用self. 来调用collectionView。此函数由addTarget() 方法调用。我在想也许将 indexPath 作为参数传递,但我不知道如何将 indexPath.item 作为参数传递,也不知道如何在 addTarget() 方法中传递参数。
func handleAccept(_ sender: UIButton) {
print("button pressed")
guard let artId = art?.artId else {return}
let approvedRef =
FIRDatabase.database().reference().child("approved_art")
approvedRef.updateChildValues([artId: 1])
let pendingRef =
FIRDatabase.database().reference().child("pending_art").child("\(artId)")
pendingRef.removeValue { (error, ref) in
if error != nil {
return
}
let layout = UICollectionViewFlowLayout()
let pendingArtCollectionViewController =
PendingArtsCollectionViewController(collectionViewLayout: layout)
DispatchQueue.main.async {
pendingArtCollectionViewController.collectionView?.reloadData()
}
}
}
【问题讨论】:
-
只需要tableview对应行的indexpath吗?
标签: ios firebase swift3 firebase-realtime-database