質問をすることでしか得られない、回答やアドバイスがある。

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

新規登録して質問してみよう
ただいま回答率
85.48%
iOS

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

Swift

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

Q&A

解決済

1回答

371閲覧

Table view cellからsegueを使って画面遷移できない

退会済みユーザー

退会済みユーザー

総合スコア0

iOS

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

Swift

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

0グッド

0クリップ

投稿2018/06/07 04:25

以下のように指定するとThread 1: signal SIGABRT と出てアプリが落ちてしまいます。

swift

1   func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { 2 performSegue(withIdentifier: "goSubDelivery", sender: nil) 3 } 4 5 override func prepare(for segue: UIStoryboardSegue, sender: Any?) { 6 if segue.identifier == "goSubDelivery" { 7 let subvc = segue.destination as! SubViewController 8 } 9 }

しかし、以下のようにすると解決されます。

swift

1   func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { 2 performSegue(withIdentifier: "goSubDelivery", sender: nil) 3 }

なぜこのようになるのでしょうか?最近iOSを勉強しはじめたので、初心者でもわかるような解説をしていただきたいです。よろしくお願いします。

全体のコードは以下のようになっていて、GithubAPIからrepositoryを取得してテーブルに表示しています。

swift

1import UIKit 2import Foundation 3 4class DeliveryController: UIViewController, UITableViewDelegate, UITableViewDataSource { 5 @IBOutlet weak var TableView: UITableView! 6 7 var repositories: [Repository]? 8 9 func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 10 return repositories?.count ?? 0 11 } 12 13 func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 14 let cell: UITableViewCell = tableView.dequeueReusableCell(withIdentifier: "repositoryCell", for: indexPath) 15 cell.textLabel!.text = repositories![indexPath.row].name! 16 return cell 17 } 18 19 func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { 20 return 80 21 } 22 23 func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { 24 performSegue(withIdentifier: "goSubDelivery", sender: nil) 25 } 26 27 override func prepare(for segue: UIStoryboardSegue, sender: Any?) { 28 if segue.identifier == "goSubDelivery" { 29 let subvc = segue.destination as! SubViewController 30 } 31 } 32 33 override func viewDidLoad() { 34 super.viewDidLoad() 35 // Do any additional setup after loading the view, typically from a nib. 36 } 37 38 override func didReceiveMemoryWarning() { 39 super.didReceiveMemoryWarning() 40 // Dispose of any resources that can be recreated. 41 } 42} 43

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

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

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

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

ベストアンサー

「Custom Class」->「Class」で設定をし忘れていました。

クラス名取得で書くとき、エラーが出てしまうのはそのせいでした。
ご迷惑おかけしました。

ありがとうございます。

投稿2018/06/07 04:28

退会済みユーザー

退会済みユーザー

総合スコア0

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

ただいまの回答率
85.48%

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

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

質問する

関連した質問