ViewControllerSwiftに書いたコードが実機では反映されるのですが、storyboardで反映されません。
Clean や Clean Build FolderあとReset Content and Settingsも試しましたが変化なしです。
import
1 2class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource { 3 4 let statusBarHeight = UIApplication.shared.statusBarFrame.height 5 6 override func viewDidLoad() { 7 super.viewDidLoad() 8 9 let tableView = UITableView() 10 11 tableView.frame = CGRect( 12 x: 0, 13 y: statusBarHeight, 14 width: self.view.frame.width, 15 height: self.view.frame.height - statusBarHeight 16 ) 17 18 tableView.delegate = self 19 20 tableView.dataSource = self 21 22 self.view.addSubview(tableView) 23 } 24 25 override func didReceiveMemoryWarning() { 26 super.didReceiveMemoryWarning() 27 } 28 29 // MARK: - UITableViewDataSource 30 31 func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 32 33 let cell = UITableViewCell(style: .subtitle, reuseIdentifier: "cell") 34 cell.accessoryType = .detailButton 35 cell.textLabel?.text = "セル\(indexPath.row + 1)" 36 cell.detailTextLabel?.text = "\(indexPath.row + 1)" 37 38 return cell 39 } 40 41 func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 42 43 return 5 44 } 45 46 // MARK: - UITableViewDelegate 47 48 func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { 49 50 print(": \(indexPath.row)") 51 } 52 53 func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { 54 return 64 55 } 56 57 func tableView(_ tableView: UITableView, accessoryButtonTappedForRowWith indexPath: IndexPath) { 58 59 print(": \(indexPath.row)") 60 } 61} 62コード
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/01/24 16:02 編集
2017/01/24 16:28 編集
2017/01/25 05:08 編集