UITableView
iOS8 のカスタム キーボードにを追加しようとしています。キーボードにはストーリーボードのようなインターフェイス ファイルがないため、プログラムで追加する必要がありますが、UITableView
表示されません。私はこれをやっています
:viewDidLoad
self.tableView = UITableView(frame: CGRectMake(0, 0, view.frame.width, view.frame.height), style: UITableViewStyle.Plain)
tableView.delegate = self;
tableView.dataSource = self;
self.view.addSubview(self.tableView)
tableView.reloadData()
次に、実装numberOfSectionsInTableView
しnumberOfRowsInSection
、cellForRowAtIndexPath
メソッドでこれを行っています:
var cell = tableView.dequeueReusableCellWithIdentifier("CopyCell", forIndexPath: indexPath) as UITableViewCell
if let cell: UITableViewCell = tableView.dequeueReusableCellWithIdentifier("CopyCell", forIndexPath: indexPath) as? UITableViewCell {
cell.textLabel!.text = "Hello World"
cell.backgroundColor = UIColor.redColor()
}else{
cell = UITableViewCell(style: UITableViewCellStyle.Default, reuseIdentifier: "CopyCell")
cell.textLabel!.text = "Hello World"
cell.backgroundColor = UIColor.redColor()
}
return cell
重要な詳細を見逃したかどうかはわかりませんが、テーブル ビューはカスタム キーボードに表示されません。それを示すために、背景とセルの色を追加しました。