シンプルなコードを実装してカスタムTableViewを作成しましたが、結果はシミュレータの黒い画面になります。テーブルを作成すると黒い画面が表示される
ここでどのような問題が考えられますか? どうすればわかりますか?
class ViewController: UIViewController, UITableViewDataSource, UITableViewDelegate {
let animals = ["Lion", "Elephant", "Monkey", "Panda"]
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return animals.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell" , for: indexPath) as! ViewControllerTableViewCell
cell.myImage.image = UIImage(named: (animals[indexPath.row] + ".jpg"))
cell.myLabel.text = animals[indexPath.row]
return (cell)
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
あなたがのtableViewのデリゲートとデータソースとしてのコントローラを設定しましたか? – Connor