NSLayoutAnchorのequalToにこの場合なにを入れればいいのですか?
いろいろ試したものの毎回Use of unresolved identifierと出ます。
import
1 2class HomeController: UICollectionViewController, UICollectionViewDelegateFlowLayout { 3 4 5 override func viewDidLoad() { 6 super.viewDidLoad() 7 navigationItem.title = "Home" 8 9 collectionView?.backgroundColor = UIColor.white 10 11 collectionView?.register(VideoCell.self, forCellWithReuseIdentifier: "cellid") 12 13 } 14 override func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { 15 return 5 16 } 17 override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { 18 let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cellid", for: indexPath) 19 20 return cell 21 } 22 23 func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { 24 return CGSize(width: view.frame.width, height: 200.0) 25 } 26 func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat { 27 return 0 28 } 29 30} 31 32class VideoCell: UICollectionViewCell { 33 override init(frame: CGRect) { 34 super.init(frame: frame) 35 setupView() 36 } 37 38 let thumbnailImageView: UIImageView = { 39 let imageView = UIImageView() 40 imageView.backgroundColor = UIColor.blue 41 imageView.translatesAutoresizingMaskIntoConstraints = false 42 return imageView 43 }() 44 45// let separatorView: UIView = { 46// let view = UIView() 47// view.backgroundColor = UIColor.black 48// view.translatesAutoresizingMaskIntoConstraints = false 49// return view 50// }() 51 52 53 func setupView(){ 54 addSubview(thumbnailImageView) 55// addSubview(separatorView) 56 57 thumbnailImageView.centerXAnchor.constraint(equalTo: .centerXAnchor) 58 59 60 } 61 required init?(coder aDecoder: NSCoder) { 62 fatalError("init(coder:) has not been implemented") 63 } 64}
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。