5
私は自分のコレクションビューを用意しています。私はdidSelectItemAt
を詳細ビューに分割しようとしています。しかし、私はちょうど各項目のログをテストしたい、それはログに記録されていません。didSelectItemAtが呼び出されていません。
私はすでに、すべてのデリゲートを設定します。
*私が間違っているのは何
class ViewController: UIViewController, UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout, UISearchBarDelegate {*
@IBOutlet weak var activityIndicatorView: UIActivityIndicatorView!
@IBOutlet weak var searchBar: UISearchBar!
@IBOutlet weak var collection: UICollectionView!
override func viewDidLoad() {
super.viewDidLoad()
collection.dataSource = self
collection.delegate = self
searchBar.delegate = self
activityIndicatorView.isHidden = true
let tap: UITapGestureRecognizer = UITapGestureRecognizer(target: self, action: "dismissKeyboard")
view.addGestureRecognizer(tap)
}
*
?
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
let movie : Movie
movie = MOVIE_ARRAY[indexPath.row]
print(movie.plot)
}
あなたはコレクションビューのデリゲートを設定しましたか? – rmaddy
didSelectItemAtの代わりにdidDeselectItemAt indexPathを使用していないか確認してください。 –
didSelectItemAtが使用されました:) 1時間のグーグルで、これが最も一般的な間違いです。はい、ビューの代理人はすべて設定されています。 –