###前提・実現したいこと
ルーレットを一時中断し、人数に合わせてUITableViewにてCellを画面に出すという練習をしたいため、UITableViewのサンプルコードなどを打っているのですが、
ソースコードを打っていくとエラーが出るのですが、このエラーを調べてもどう対応すべきか理解できませんでした・・・。
どうかご教示お願いします。
UITableViewはmainStoryboardにてViewControllerにUITableViewを入れて
作成しております
###発生している問題・エラーメッセージ
発生している箇所は
tableView.dataSource = self
というところで、エラーメッセージとしては
Value of type 'UITableView' has no member 'dataSource'
です
###該当のソースコード
swift
1import UIKit 2 3class RandomController: UIViewController, UITableViewDelegate, UITableViewDataSource { 4 5 @IBOutlet weak var tableView: UITableView! 6 7 //セルに表示するテキスト 8 let texts = ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"] 9 10 override func viewDidLoad() { 11 super.viewDidLoad() 12 13 //デリゲートとデータソースを設定 14 tableView.delegate = self 15 tableView.detaSource = self 16 17 // Do any additional setup after loading the view. 18 } 19 20 override func didReceiveMemoryWarning() { 21 super.didReceiveMemoryWarning() 22 // Dispose of any resources that can be recreated. 23 } 24 25 func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 26 // Cellの数を決める。 27 return texts.count 28 } 29 30 func tableView(_ tableView: UITableView, cellForRowAt indexPath:IndexPath)->UITableViewCell{ 31 //Cellの内容を決める。 32 let cell = tableView.dequeueReusableCell(withIdentifier: "randomCell", for: indexPath) 33 34 cell.textLabel!.text = texts[indexPath.row] 35 36 return cell 37 } 38 39} 40
###補足情報(言語/FW/ツール等のバージョンなど)
Swift3,Xcode8.3です。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/05/09 05:33
2017/05/09 05:34
2017/05/09 05:39
2017/05/09 05:45
2017/05/09 05:47