2016-07-09 2 views
0

무슨 일이 일어나고 있는지 혼란 스러워요. 프로그래밍에 익숙하지 않아서 콜렉션 뷰에 관한 튜토리얼을하고 있어요. 나는 모든 것을 올바르게하고 있다고 믿지만, 맞았습니다. -[UIView tableView:numberOfRowsInSection:]: unrecognized selector sent to instance . http://www.thorntech.com/2015/08/want-your-swift-app-to-scroll-in-two-directions-like-netflix-heres-how/UITableView 인식 할 수없는 셀렉터를 인스턴스로 보냄

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 대리자를 설정하거나 유무 : 여기

튜토리얼입니다.?

Tableview 대리인을 으로 프로그래밍 방식으로 설정하십시오. 스토리 보드를 이용

yourtableview.dataSource=self 

또는

이미지 아래 쇼 UITableViewDataSource하는 의 tableview 대리자를 설정. 당신이 다른보기로 잘못 UITableViewDataSource를 설정하면

enter image description here

또는

확인하시기 바랍니다.

+0

효과가 있습니다. 덕분에 직접 viewcontroller 대신 tableview에 내 데이터 소스를 설정 – Hightower98

+0

가장 환영 형제 –

관련 문제