前提・実現したいこと
1つ目とは異なるページに2つ目のUICollectionViewを実行したいです。
※Storyboardも操作しています。
発生している問題・エラーメッセージ
1つ目 Invalid redeclaration of 'collectionView(_:numberOfItemsInSection:)' 2つ目 Invalid redeclaration of 'collectionView(_:cellForItemAt:)' 3つ目 Type 'ViewController' does not conform to protocol 'UICollectionViewDataSource' 4つ目 Cannot convert value of type 'IndexPath.Type' to expected argument type 'IndexPath'
該当のソースコード
import UIKit class ViewController: UIViewController,UICollectionViewDataSource,UICollectionViewDelegate { let array:[String] = ["binsen1","binsen2","binsen3","binsen4","binsen5","binsen6","binsen7","binsen8"] let array1:[String] = ["huto1","huto2","huto3","huto4","huto5","huto6","huto7","huto8"] override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. } //NUmber of Views その1 func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { return array.count } //NUmber of Views その2 func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { return array1.count } //Populate view その1 func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cell", for: indexPath) as! myCell cell.myimageView.image = UIImage(named: array[indexPath.row] + ".jpg" ) return cell } //Populate view その2 func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { let cell1 = collectionView.dequeueReusableCell(withReuseIdentifier: "cell1", for: IndexPath) as! myCell1 cell1.myimageView1.image = UIImage(named: array1[indexPath.row] + ".jpg" ) return cell1 } }
補足情報(FW/ツールのバージョンなど)
https://www.youtube.com/watch?v=nPf5X5z0eA4&t=596s
この動画をみて1つ目は成功したのですが、2つ目はエラーが出てしまいました。
2つ目のコーディングの仕方がわからず苦戦しています。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/11/26 04:57
退会済みユーザー
2018/11/26 07:40 編集
2018/11/26 09:00
2018/11/28 05:21
2018/11/28 14:21