サンプルでテーブルビューのコードを作って動作確認後
そのサンプルをコピペして別のプロジェクトで表示させようと思ったのですが
エラーも出ていない状態でテーブルビュー自体表示されない(ビューが真っ白)なのですがどこを確認すれば原因がわかるのか教えていただきたいです。
テーブル自体の生成はログで確認できているのですが
表示がうまくいかない状態です。
色々調べたのですが
自分と同じ状態でトラブっている記事が見つからなかったので
よろしくお願いします。
情報不足だと指摘されるかもしれませんが
どこの情報を添付すればいいかもよくわからないので
確認方法を教えていただければ幸いです。
追加情報
import UIKit class ViewController: UIViewController,UITableViewDelegate,UITableViewDataSource,UIToolbarDelegate,UIScrollViewDelegate { @IBOutlet weak var scrollview: UIScrollView! // テーブルページ数 var teburupejicount:Int = 0//テーブルセルの押された値 // テーブルページ表示されているページ var teburupejihyoujicount:Int = 0//表示されているページ var indexcount:Int = 0//インデックスの値 var myTableView: [UITableView] = [] // テーブルデータ var serutaitoru = [[String]]()//セル内のタイトル var seruhituke = [[String]]()//セル内の日付 override func viewDidLoad() { super.viewDidLoad() } /* ScrollViewが移動した際に呼ばれる. */ func scrollViewDidScroll(_ scrollView: UIScrollView) { // スクロール中の処理 print("\(scrollView.contentOffset.x)") print("didScroll") } func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) { if fmod(scrollView.contentOffset.x, scrollView.frame.maxX) == 0 { }else if scrollview.contentOffset.x == self.view.frame.width{ }else{ print(teburupejicount) } print("teburupejicount \(teburupejicount)") print("teburupejihyoujicount \(teburupejihyoujicount)") print(teburupejicount) } // セルのスイッチ internal func onClickMySwicth(sender: UISwitch){ } // ステータスバーの幅 var barHeight: CGFloat = UIApplication.shared.statusBarFrame.size.height var width:CGFloat = 0 var height:CGFloat = 0 func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { return 60 } // UIScrollView. var scrollView: UIScrollView! // ページ番号. let pageSize = 2 override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) serutaitoru = [["ご飯", "味噌汁", "焼き魚"],["天津飯", "チャーハン", "八宝菜", "酢豚", "肉まん"]] seruhituke = [["1980/2/27", "1983/8/25", "2016/10/10"],["2016/6/24", "2014/12/16", "2014/8/16", "2014/11/16", "2018/12/3"]] width = CGFloat(self.view.frame.maxX) height = CGFloat(self.view.frame.maxY) // Status Barの高さを取得. let barHeight: CGFloat = UIApplication.shared.statusBarFrame.size.height // スクロールビュー // ScrollViewの設定. scrollView = UIScrollView(frame: CGRect(x: 0, y: barHeight, width: width, height: height - barHeight)) scrollView.showsHorizontalScrollIndicator = false; scrollView.showsVerticalScrollIndicator = false scrollView.isPagingEnabled = true scrollView.delegate = self scrollView.contentSize = CGSize(width:CGFloat(pageSize) * width, height:0) self.view.addSubview(scrollView) for i in 0 ..< pageSize { let tableView: UITableView = UITableView(frame: CGRect(x: CGFloat(i) * width, y: barHeight, width: width, height: height - barHeight)) tableView.estimatedRowHeight = 60 tableView.rowHeight = UITableViewAutomaticDimension tableView.tag = i tableView.dataSource = self tableView.delegate = self tableView.register(UINib(nibName: "TableViewCell", bundle: nil), forCellReuseIdentifier: "MyCell") myTableView.append(tableView) scrollView.addSubview(myTableView[i]) print("テーブル\(i)") } print("myTableView[]: \(myTableView)") } // セルがタップされた時遷移される func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() } func numberOfSections(in tableView: UITableView) -> Int { return 1 } // セルの個数を指定するデリゲートメソッド(必須) func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { if tableView.tag == 0 { return serutaitoru[0].count }else if tableView.tag == 1 { return serutaitoru[1].count }else{ return 0 } } // セルに値を設定するデータソースメソッド(必須) func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCell(withIdentifier: "MyCell", for: indexPath) as! TableViewCell // 配列の中身をすべて各セルに表示させる cell.Label1.text = serutaitoru[tableView.tag][indexPath.row] cell.Label2.text = seruhituke[tableView.tag][indexPath.row] return cell } }
swift3.0 xcode8.1 beta
回答1件
あなたの回答
tips
プレビュー