質問するログイン新規登録

Q&A

解決済

2回答

12588閲覧

基本的なTableViewの表示で行き詰まっています

norinori365

総合スコア1

TableView

TableView(UITableView)とは、リスト形式で表示するコントロールで、ほとんどのアプリに使用されています。画面を「行」に分けて管理し、一般的には各行をタップした際に詳細画面に移動します。

iOS

iOSとは、Apple製のスマートフォンであるiPhoneやタブレット端末のiPadに搭載しているオペレーションシステム(OS)です。その他にもiPod touch・Apple TVにも搭載されています。

Xcode

Xcodeはソフトウェア開発のための、Appleの統合開発環境です。Mac OSXに付随するかたちで配布されています。

Swift

Swiftは、アップルのiOSおよびOS Xのためのプログラミング言語で、Objective-CやObjective-C++と共存することが意図されています

iPhone

iPhoneとは、アップル社が開発・販売しているスマートフォンです。 同社のデジタルオーディオプレーヤーiPodの機能、電話機能、インターネットやメールなどのWeb通信機能の3つをドッキングした機器です。

0グッド

0クリップ

投稿2020/09/07 23:51

0

0

前提・実現したいこと

Xcode(Swift)でSotryboardを使ったサンプルコードの基本的なTableViewを表示するテストをしています。
TableViewとTableCellViewを実装し、
ビルドすると以下のエラーメッセージが発生しました。
他の類似したTableViewのサンプルコードも試してみましたが、
同様のエラーが出て止まってしまいます。
再起動やXcodeのアップデートも行いましたが、
解決に至りませんでした。
ヒントやアドバイスをいただけると幸いです。

発生している問題・エラーメッセージ

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate の場所で
下記のエラーメッセージが出て、Tableが表示されません。

エラーメッセージ
Thread 1: Exception: "unable to dequeue a cell with identifier Cell - must register a nib or a class for the identifier or connect a prototype cell in a storyboard"

また、Xcodeの下のペインに下記のメッセージが出ていました。

2020-09-08 08:28:37.524341+0900 testTableView04[1816:57768] *** Assertion failure in -[UITableView _dequeueReusableCellWithIdentifier:forIndexPath:usingPresentationValues:], /Library/Caches/com.apple.xbs/Sources/UIKitCore_Sim/UIKit-3920.31.102/UITableView.m:8724
2020-09-08 08:28:37.530356+0900 testTableView04[1816:57768] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'unable to dequeue a cell with identifier Cell - must register a nib or a class for the identifier or connect a prototype cell in a storyboard'

該当のソースコード

// // ViewController.swift // testTableView04 // import UIKit class ViewController: UIViewController, UITableViewDataSource, UITableViewDelegate{ var array = ["a", "b", "c"] func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return array.count } func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell: UITableViewCell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) // セルに表示する値を設定する cell.textLabel!.text = array[indexPath.row] return cell } override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view. } }

delegateとdatasourceは、下記のようにViewControllerに接続しています

他の、TableViewのサンプルを試したのですが、
同じように「Thread 1: Exception: "unable to dequeue a cell with identifier Cell - must register a nib or a class for the identifier or connect a prototype cell in a storyboard"」というエラーが出て止まってしまいます。

                

補足情報(FW/ツールのバージョンなど)

Xcode 11.7
iPhone8Plus (Simulator)
macOS Catalina 10.15.6
MacBook air 2017

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

guest

回答の取得に失敗しました

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.25%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問