swiftでUITableViewとNavigationControllerを使ってリストを表示し、画面遷移させたり、そこから元の画面に戻るといったアプリを練習で作りました。
ですが、シミュレータを起動したところ、リストの外枠の部分だけしか画面上には表示されず、肝心のリストの内容が表示されませんでした。
改善の方をお願いします。
下記にstoryboardとソースコードの方を載せておきます。
swift
1import UIKit 2 3class ViewController: UIViewController { 4 5 var items = [Dictionary<String,String>]() 6 7 8 override func viewDidLoad() { 9 super.viewDidLoad() 10 // Do any additional setup after loading the view, typically from a nib. 11 12 items.append(["name":"りんご","detail":"テスト1"]) 13 14 items.append(["name":"みかん","detail":"テスト2"]) 15 16 items.append(["name":"めろん","detail":"テスト3"]) 17 18 items.append(["name":"すいか","detail":"テスト4"]) 19 20 } 21 22 override func didReceiveMemoryWarning() { 23 super.didReceiveMemoryWarning() 24 // Dispose of any resources that can be recreated. 25 } 26 27 func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 28 29 //リストの件数を返す 30 return items.count 31 } 32 33 // セルをitemsから設定する処理 34 func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell{ 35 let cell: UITableViewCell = UITableViewCell(style: UITableViewCellStyle.Subtitle, reuseIdentifier: "Cell") 36 37 cell.textLabel?.text = items[indexPath.row]["name"]! 38 cell.detailTextLabel?.text = items[indexPath.row]["detail"] 39 40 return cell 41 } 42 43 //セルがクリックされたときに発生するイベント 44 func tableView(tableView: UITableViewCell, didselectRowAtIndexPath indexPath: NSIndexPath) -> Void { 45 performSegueWithIdentifier("segue1", sender: self) 46 } 47 48} 49 50
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2015/09/04 12:55