質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Swift 2

Swift 2は、Apple社が独自に開発を行っている言語「Swift」のアップグレード版です。iOSやOS X、さらにLinuxにも対応可能です。また、throws-catchベースのエラーハンドリングが追加されています。

Q&A

解決済

1回答

2984閲覧

does not conform to protocol 'UICollectionViewDataSource'を解決したい

mochi9902

総合スコア29

Swift 2

Swift 2は、Apple社が独自に開発を行っている言語「Swift」のアップグレード版です。iOSやOS X、さらにLinuxにも対応可能です。また、throws-catchベースのエラーハンドリングが追加されています。

0グッド

0クリップ

投稿2016/08/09 02:44

以下のソースコードで題名通りのエラーが発生しています。
UICollectionViewDataSourceに必要最低限のメソッドは定義したつもりですが、
解決されません。
足りないメソッドなど、ご教授お願いします。

swift

1class CalendarViewController: UIViewController, UICollectionViewDataSource, UICollectionViewDelegate, UICollectionViewDelegateFlowLayout { 2 3 @IBOutlet weak var calenderCollectionView: UICollectionView! 4 @IBOutlet weak var headerTitle: UILabel! 5// 中略 6 7 override func viewDidLoad() { 8 super.viewDidLoad() 9 10 calenderCollectionView.delegate = self 11 calenderCollectionView.dataSource = self 12 calenderCollectionView.backgroundColor = UIColor.whiteColor() 13 headerTitle.text = changeHeaderTitle(selectedDate) 14 } 15 16 func colectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { 17 if section == 0 { 18 return 7 19 } else { 20 return dateManager.daysAcquisition() 21 } 22 } 23 24 func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell { 25 let cell = collectionView.dequeueReusableCellWithReuseIdentifier("cell", forIndexPath: indexPath) as! CalendarCell 26 if indexPath.row % 7 == 0 { 27 cell.textLabel.textColor = UIColor.lightRed() 28 } else if indexPath.row % 7 == 6 { 29 cell.textLabel.textColor = UIColor.lightBlue() 30 } else { 31 cell.textLabel.textColor = UIColor.grayColor() 32 } 33 34 if indexPath.section == 0 { 35 cell.textLabel.text = self.weekArray[indexPath.row] 36 } else { 37 cell.textLabel.text = dateManager.conversionDateFormat(indexPath) 38 } 39 return cell 40 } 41 42 // 中略 43}

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

ベストアンサー

スペルミスですね、、、collectionViewlがひとつ足りないようです。

swift

1func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { 2 if section == 0 { 3 return 7 4 } else { 5 return dateManager.daysAcquisition() 6 } 7}

投稿2016/08/09 03:25

_Kentarou

総合スコア8490

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問