こんにちは
TableViewを使いたくてテストしているのですが、配列に指定した文字をcellにして出すというのができません
swift
1import UIKit 2 3class ViewController: UIViewController, UITableViewDataSource, UITableViewDelegate { 4 5 var array: String = ["hoge","fuga","miso"] //これをセルにして出したい 6 7 @IBOutlet weak var tableView: UITableView! 8 9 override func viewDidLoad() { 10 super.viewDidLoad() 11 // Do any additional setup after loading the view, typically from a nib. 12 } 13 14 override func didReceiveMemoryWarning() { 15 super.didReceiveMemoryWarning() 16 // Dispose of any resources that can be recreated. 17 } 18 19 func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 20 return array.count 21 } 22 23 func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { 24 let cell = tableView.dequeueReusableCellWithIdentifier("hoge", forIndexPath: indexPath)//hogeがidentifer 25 cell.textLabel!.text = "\(array[indexPath.row])" 26 return cell 27 } 28}
しかし、シミュレータは真っ白なまま何も出てこないのです
何が間違っているのでしょうか?よろしくお願いいたします。
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/05/02 03:15