###前提・実現したいこと
Xcode8、Swift3を使ってテーブルビューにフォントを出力するプログラムを作ろうとしています。
storyboard上にTable Viewを置き、
それをView ControllerのdataSourseとdelegateに繋ぎました。
![
その後、2つのプロトコルを追加し、
フォントを配列に入れセルに表示しようとしました。
Swift2の教科書を使っているために、
ところどころ変わっていて、
調べたのですが対処法がわからない状態です。
お力を貸していただけると嬉しいです。
###発生している問題・エラーメッセージ
エラーメッセージ1(class ViewController: UIView 〜の部分) Type "ViewController" does not conform to protocol "UITableViewDataSourse" エラーメッセージ2(return celloの部分) Cannot convert return expression of type "UITableView"
###該当のソースコード
Swift3
1import UIKit 2 3class ViewController: UIViewController ,UITableViewDataSource, UITableViewDelegate{ 4 5 var fontName_array:[String] = [] 6 7 override func viewDidLoad() { 8 super.viewDidLoad() 9 // Do any additional setup after loading the view, typically from a nib. 10 11 for fontFamilyName in UIFont.familyNames{ 12 for fontname in UIFont.fontNames(forFamilyName: fontFamilyName as String){ 13 fontName_array.append(fontname as String) 14 } 15 } 16 } 17 18 func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 19 return fontName_array.count 20 } 21 22 23 func tableView(_ tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath)-> 24 UITableView{ 25 let cell = UITableViewCell(style: UITableViewCellStyle.subtitle, reuseIdentifier:"mycell") 26 27 let fontname = fontName_array[indexPath.row] 28 cell.textLabel?.font = UIFont(name: fontname, size: 18) 29 cell.textLabel?.text = "ABCDE abcde 0123445 あいうえお" 30 31 cell.detailTextLabel?.textColor = UIColor.brown 32 cell.detailTextLabel?.text = fontname 33 return cell 34 } 35 36 override func didReceiveMemoryWarning() { 37 super.didReceiveMemoryWarning() 38 // Dispose of any resources that can be recreated. 39 } 40 41 42} 43
###試したこと
課題に対してアプローチしたことを記載してください
###補足情報(言語/FW/ツール等のバージョンなど)
より詳細な情報
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/10/10 00:17