誰かが私のUIViewをシミュレータで隠さないと言うことができますか? コードが機能していて、関数に追加した数値が表示されますが、それでも機能しません。UICollectionViewCellでの表示を非表示にする
基本的にはセルをタップして、セル内のgreyViewが消えてしまいます。
override func viewDidLoad() {
super.viewDidLoad()
let lpgr = UITapGestureRecognizer(target: self, action: #selector(ViewController.handleTap(_:)))
lpgr.numberOfTapsRequired = 1
lpgr.delaysTouchesBegan = true
lpgr.delegate = self
AlarmCollection.addGestureRecognizer(lpgr)
}
// MARK: UICollectionViewCell
func handleTap(gestureReconizer: UITapGestureRecognizer) {
if gestureReconizer.state != UIGestureRecognizerState.Ended {
return
}
let p = gestureReconizer.locationInView(AlarmCollection)
let indexPath = AlarmCollection.indexPathForItemAtPoint(p)
if let index = indexPath {
var cell = AlarmCollection.cellForItemAtIndexPath(index)
// do stuff with your cell, for example print the indexPath
print(index.row)
updateView(indexPath!)
} else {
print("Could not find index path")
}
}
func updateView(indexPath: NSIndexPath) {
let cell = AlarmCollection.dequeueReusableCellWithReuseIdentifier(reuseIdentifier, forIndexPath: indexPath) as! AlarmItemCell
cell.greyView.hidden = true
print("2")
}
EDIT:
// MARK: UICollectionViewCell
func handleTap(gestureReconizer: UITapGestureRecognizer) {
if gestureReconizer.state != UIGestureRecognizerState.Ended {
return
}
let p = gestureReconizer.locationInView(AlarmCollection)
let indexPath = AlarmCollection.indexPathForItemAtPoint(p)
if let index = indexPath {
var cell = AlarmItemCell()
// do stuff with your cell, for example print the indexPath
print(index.row)
updateView()
} else {
print("Could not find index path")
}
}
func updateView(cell: UICollectionViewCell) {
if let cell = cell as? AlarmItemCell {
cell.greyView.hidden = true
}
print("2")
}
EDIT 2:
if let index = indexPath {
let cell = AlarmCollection.cellForItemAtIndexPath(index)
updateView(cell!)
}
あなたが投稿する前にあなたのコードをクリーンアップする必要があります。 'didReceiveMemoryWarning()'のような不必要なコードや、 ''読み込み後に追加設定をする ''のような不要なコメントを残すと、読みにくくなり、助けてくれる人が奪われる可能性があります。あなたの投稿を編集できますか? – Andrej
ありがとうございます。 –