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

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

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

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

Swift

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

Q&A

解決済

1回答

1245閲覧

UITableViewをリンクさせると”Thread 1: signal SIGABRT”

AppDvl

総合スコア58

Xcode

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

Swift

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

0グッド

0クリップ

投稿2019/07/01 12:40

編集2019/07/01 14:48

#####聞きたいこと
ストリートビューで”Memo”というビューにリンクさせた途端に”Thread 1: signal SIGABRT”のエラーになる、これの直し方

######試したこと
1.リンクを削除してシミュレーターてテストするとエラーは起きない(空のセルが表示される)
2.リンクさせ、シミュレーターでテストすると”Thread 1: signal SIGABRT”
3.Identifierを変えてみたが結果は”Thread 1: signal SIGABRT”

######参考にした動画
https://www.youtube.com/watch?v=ctOzkgGXHQE

######お願い
ネットで”Thread 1: signal SIGABRT”について調べてみました。
ストーリーボードのリンクのさせ方が悪いと出るみたいです。
私の場合、MemoとTableVieWのリンクのさせ方だと思うのですが、解決方法がわかりません。
どなたかご教授お願いします。

#####当該のコード

//テーブルビューの設定//////////////////////////////////////////////////////////////////////////////////// // ・行の数 func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return coordinates.count } // ・セルのスタイル、何を表示するか決める func tableView(tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let coordinatesCell = UITableViewCell(style: UITableViewCell.CellStyle.default , reuseIdentifier: "cds") coordinatesCell.textLabel?.text = coordinates[indexPath.row] return coordinatesCell } ////////////////////////////////////////////////////////////////テーブルビューの設定//

イメージ説明
イメージ説明
イメージ説明

#####コード全文

// // MemoViewController.swift // import UIKit import MapKit import CoreLocation class MemoViewController: UIViewController ,UIImagePickerControllerDelegate ,UINavigationControllerDelegate ,CLLocationManagerDelegate ,UITableViewDelegate{ @IBOutlet weak var mapTypeLabel: UILabel! @IBOutlet weak var saveButton: UIBarButtonItem! var locationManager:CLLocationManager! var memo: String?//saveボタン用 @IBOutlet weak var memoTextField: UITextField! @IBOutlet weak var map: MKMapView! @IBOutlet weak var latiudeLabel: UILabel! @IBOutlet weak var longitudeLabel: UILabel! @IBOutlet weak var horizontalLabel: UILabel! @IBOutlet weak var verticalLabel: UILabel! @IBOutlet weak var measureButton: UIButton! var coordinates = ["130.1111","33.1111","130.2222","33.2222"] let width = UIScreen.main.bounds.size.width//画面の幅 let height = UIScreen.main.bounds.size.height//画面の高さ var cnt : Int = 0 //表示領域を指定:はじめの1回だけ現在地をセンターにするためif cntを設置 @IBOutlet var coordinateCollection: [UICollectionView]! @IBAction func measureButton(_ sender: Any) { print("開始") } // 画面の切替 @objc func mapViewTypeBtnThouchDown(_ sender: Any) { switch map.mapType { case .satelliteFlyover: // 地図よりもデータを強調○ map.mapType = .standard mapTypeLabel.text = "standard" mapTypeLabel.frame = CGRect(x:10, y: 130, width:90, height:30) print("standard") break case .standard: // 3D航空写真☓ map.mapType = .satelliteFlyover mapTypeLabel.text = "3D" mapTypeLabel.frame = CGRect(x:10, y: 130, width:33, height:30) print("satelliteFlyover") break @unknown default: break } } override func viewDidLoad() { super.viewDidLoad() //テーブルビューの設定///////////////////////////////// // ・行の数 func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return coordinates.count } // ・セルのスタイル、何を表示するか決める func tableView(tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let coordinatesCell = UITableViewCell(style: UITableViewCell.CellStyle.default , reuseIdentifier: "cds") coordinatesCell.textLabel?.text = coordinates[indexPath.row] return coordinatesCell } ////////////////////テーブルビューの設定// horizontalLabel.frame = CGRect(x:10, y: 165, width:200, height:30) verticalLabel.frame = CGRect(x:10, y: 165, width:200, height:30) latiudeLabel.frame = CGRect(x:10, y: 165, width:200, height:30) longitudeLabel.frame = CGRect(x:map.frame.origin.x + map.frame.size.width, y: map.frame.origin.y + map.frame.size.height, width:300, height:30) locationManager = CLLocationManager() locationManager.desiredAccuracy = kCLLocationAccuracyBest //最高精度 locationManager.requestAlwaysAuthorization() locationManager.delegate = self // CLLocationManagerDelegat locationManager.startUpdatingLocation()//観測開始 self.navigationItem.title = "Edit Memo" if let memo = self.memo{ self.memoTextField.text = memo } self.updateSaveButtonState() // 地図の設定〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜 map.mapType = MKMapType.satelliteFlyover map.userTrackingMode = .follow var mapViewType: UIButton! mapViewType = UIButton(type: UIButton.ButtonType.detailDisclosure) ///////////// mapViewType.frame = CGRect(x:10, y: 165, width:33, height:30) mapViewType.layer.backgroundColor = UIColor(white: 1, alpha: 0.65).cgColor mapViewType.layer.borderWidth = 0.5 mapViewType.layer.borderColor = UIColor.blue.cgColor self.view.addSubview(mapViewType) ///////////// mapTypeLabel.frame = CGRect(x:10, y: 130 , width:33, height:30) mapTypeLabel.layer.backgroundColor = UIColor(white: 1, alpha: 0.8).cgColor mapTypeLabel.layer.borderWidth = 0.5 mapTypeLabel.layer.borderColor = UIColor.blue.cgColor self.view.addSubview(mapTypeLabel) mapTypeLabel.text = "3D" // 地図の表示タイプを切り替える関数 mapViewType.addTarget(self, action: #selector(mapViewTypeBtnThouchDown(_:)), for: .touchDown) } private func updateSaveButtonState(){ let memo = self.memoTextField.text ?? "" self.saveButton.isEnabled = !memo.isEmpty } @IBAction func memoTextFieldChanged(_ sender: Any) { updateSaveButtonState() } @IBAction func cancel(_ sender: Any) { if self.presentingViewController is UINavigationController { self.dismiss(animated: true, completion: nil) } else { self.navigationController?.popViewController(animated: true) } } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() } override func prepare(for segue: UIStoryboardSegue, sender: Any?) { guard let button = sender as? UIBarButtonItem, button === self.saveButton else { return } self.memo = self.memoTextField.text ?? "" } } //位置情報の許可============= extension MemoViewController { func locationManager(_ manager: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus) { switch status { case .notDetermined: print("ユーザーはこのアプリケーションに関してまだ選択を行っていません") locationManager.requestAlwaysAuthorization() break case .denied: print("ローケーションサービスの設定が「無効」になっています (ユーザーによって、明示的に拒否されています)") let alert : UIAlertController = UIAlertController(title: "測定を続けるには", message: "設定 > プライバシー > 位置情報サービス で、位置情報サービスの利用を許可して下さい。", preferredStyle: .alert) let okAction = UIAlertAction(title:"OK", style: .default,handler: nil) alert.addAction(okAction) present(alert,animated: true,completion: nil) break case .restricted: print("このアプリケーションは位置情報サービスを使用できません(ユーザによって拒否されたわけではありません)") break case .authorizedAlways: print("常時、位置情報の取得が許可されています。") break case .authorizedWhenInUse: print("起動時のみ、位置情報の取得が許可されています。") locationManager.requestAlwaysAuthorization() break @unknown default: break } } //=====================位置情報の許可 func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {//GPSが更新すると呼ばれる let location : CLLocation = locations[0] let currentlocation = location.coordinate if cnt == 0{ let reg : MKCoordinateRegion = MKCoordinateRegion(center: currentlocation,latitudinalMeters: 100,longitudinalMeters: 100) map.region = reg let viewPoint :CLLocationCoordinate2D = CLLocationCoordinate2DMake(location.coordinate.latitude-0.005, location.coordinate.longitude) map.showsBuildings = true map.isPitchEnabled = true let cameraVR : MKMapCamera = MKMapCamera(lookingAtCenter: currentlocation, fromEyeCoordinate: viewPoint, eyeAltitude: 100) map.camera = cameraVR cnt = 1 } latiudeLabel.text = String("緯度:(location.coordinate.latitude)" ) longitudeLabel.text = String("経度:(location.coordinate.longitude)") horizontalLabel.text = String("水平精度:(location.horizontalAccuracy)") verticalLabel.text = String("垂直精度:(location.verticalAccuracy)") } }

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

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

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

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

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

MasakiHori

2019/07/02 00:18

エディタ下部のコンソールに表示されているエラーをすべて質問に追記してください
fuzzball

2019/07/02 00:24

「Memo」って何ですか?
AppDvl

2019/07/02 14:16

MasakiHoriさん fuzzballさん お返事が遅くなってしまいすいません。 dsuzukiの回答していただいたとおり「UITableViewDataSource」を継承したらエラーが出なくなり解決しました。 私の質問に関しを持っていいただき、ありがとうございました。
guest

回答1

0

ベストアンサー

Swift

1class MemoViewController: 2 UIViewController 3 ,UIImagePickerControllerDelegate 4 ,UINavigationControllerDelegate 5 ,CLLocationManagerDelegate 6 ,UITableViewDelegate 7 ,UITableViewDataSource { //★ 8 .... 9 10 override func viewDidLoad() { 11 super.viewDidLoad() 12 .... 13 } 14 15 "当該のコード" 16} 17

もしくは

Swift

1class MemoViewController:... { 2 .... 3} 4extension MemoViewController { 5 .... 6} 7extension MemoViewController: UITableViewDataSource { //★ 8 "当該のコード" 9}

func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
は共にUITableViewDataSourceに定義されているfuncです。

StoryboardでUITableViewと紐付けるdataSourceの実装になります。

投稿2019/07/02 04:30

dsuzuki

総合スコア1682

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

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

AppDvl

2019/07/02 14:22

dsuzukiさん ご回答頂いたとおり「UITableViewDataSource」を継承したらエラーがああ出なくなりました。 とても、”Thread 1: signal SIGABRT”はストーリーボードのリンクの問題だと思いこんでいた自分では解決出来なかっただろうとおもいます。 大変感謝しております。ありがとうございました。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

ただいまの回答率
85.50%

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

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

質問する

関連した質問