2016-07-09 11 views
0

何が起きているのか混乱しています。私はプログラミングの初心者としてコレクションビューのチュートリアルを行っています。私はすべてを正しくやっていると信じていますが、ヒットします。-[UIView tableView:numberOfRowsInSection:]: unrecognized selector sent to instance 。ここでUITableViewインスタンスに送信されたセレクタが認識されない

はチュートリアルです: http://www.thorntech.com/2015/08/want-your-swift-app-to-scroll-in-two-directions-like-netflix-heres-how/

import UIKit 

class ViewController: UIViewController, UITableViewDataSource { 

var categories = ["Action", "Drama", "Science Fiction", "Kids", "Horror"] 

func tableView(tableView: UITableView, titleForHeaderInSection section: Int) -> String? { 
    return categories[section] 
} 

func numberOfSectionsInTableView(tableView: UITableView) -> Int { 
    return categories.count 
} 

func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 
    return 1 
} 

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { 
    let cell = tableView.dequeueReusableCellWithIdentifier("cell") as! CategoryRow 
    return cell 
} 

答えて

3

を使用すると、ストーリーボードやprogrammtically使用してUITableViewDataSourceにテーブルビューのデリゲートを設定していますか。?

tableviewデリゲートをに設定すると、プログラムによってUITableViewDataSourceが呼び出されます。ストーリーボードを使用して

yourtableview.dataSource=self 

又は

は、画像の下ショーをUITableViewDataSourceするテーブルビューのデリゲートを設定します。あなたが他のビューに間違ったUITableViewDataSourceを設定している場合

enter image description here

それとも

チェック。

+0

これは機能しました。ありがとう私はviewcontrollerの代わりに直接tableviewに自分のデータソースを設定 – Hightower98

+0

ほとんどの仲間の仲間 –

関連する問題