Я получаю ошибку при попытке создать tableView в swift для iPhone.
Привет, я смотрю много учебников, чтобы наконец создать приложение для магазина приложений. Недавно меня заинтересовали tableViews, поэтому я следовал многим учебникам и, кажется, всегда получаю ошибку, в то время как люди в учебнике успешно создают свое приложение. Когда я пытаюсь запустить мое приложение, сборка останавливается и я получаю исключение в классе AppDelegate на строке, где написано «class AppDelegate. » исключение — «Thread 1 : signal SIGABRT»
и для тех, кто заинтересован, вот сообщение в консоли.
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'must pass a class of kind UITableViewHeaderFooterView' *** First throw call stack: ( 0 CoreFoundation 0x0000000109c80f35 __exceptionPreprocess + 165 1 libobjc.A.dylib 0x000000010b7c4bb7 objc_exception_throw + 45 2 CoreFoundation 0x0000000109c80e6d +[NSException raise:format:] + 205 3 UIKit 0x000000010a5fb254 -[UITableView registerClass:forHeaderFooterViewReuseIdentifier:] + 247 4 tableviewtes 0x0000000109a9cc3c _TFC12tableviewtes14ViewController11viewDidLoadfS0_FT_T_ + 460 5 tableviewtes 0x0000000109a9ccd2 _TToFC12tableviewtes14ViewController11viewDidLoadfS0_FT_T_ + 34 6 UIKit 0x000000010a631a90 -[UIViewController loadViewIfRequired] + 738 7 UIKit 0x000000010a631c8e -[UIViewController view] + 27 8 UIKit 0x000000010a550ca9 -[UIWindow addRootViewControllerViewIfPossible] + 58 9 UIKit 0x000000010a551041 -[UIWindow _setHidden:forced:] + 247 10 UIKit 0x000000010a55d72c -[UIWindow makeKeyAndVisible] + 42 11 UIKit 0x000000010a508061 -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 2628 12 UIKit 0x000000010a50ad2c -[UIApplication _runWithMainScene:transitionContext:completion:] + 1350 13 UIKit 0x000000010a509bf2 -[UIApplication workspaceDidEndTransaction:] + 179 14 FrontBoardServices 0x000000010d3512a3 __31-[FBSSerialQueue performAsync:]_block_invoke + 16 15 CoreFoundation 0x0000000109bb653c __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12 16 CoreFoundation 0x0000000109bac285 __CFRunLoopDoBlocks + 341 17 CoreFoundation 0x0000000109bac045 __CFRunLoopRun + 2389 18 CoreFoundation 0x0000000109bab486 CFRunLoopRunSpecific + 470 19 UIKit 0x000000010a509669 -[UIApplication _run] + 413 20 UIKit 0x000000010a50c420 UIApplicationMain + 1282 21 tableviewtes 0x0000000109a9faee top_level_code + 78 22 tableviewtes 0x0000000109a9fb2a main + 42 23 libdyld.dylib 0x000000010bf9e145 start + 1 ) libc++abi.dylib: terminating with uncaught exception of type NSException (lldb)
Поделиться Источник 16 декабря 2014 в 21:00
3 ответа
Возможно, функция, которую вы хотите использовать, это
tableView.registerClass(UITableViewController.self, forCellReuseIdentifier: cellIdentifier)
tableView.registerClass(UITableViewController.self, forHeaderFooterViewReuseIdentifier: cellIdentifier)
Надеюсь, это все.
Поделиться 05 августа 2015 в 18:01
Я думаю, что это крохотная ошибка.
tableView.register(UITableView.self, forCellReuseIdentifier: "cell")
Вам нужно использовать:
tableView.register(UITableViewCell.self, forCellReuseIdentifier: "cell")
Обратите внимание, что первый аргумент в функции регистрации должен быть UITableViewCell , а не UITableView
Поделиться 13 декабря 2020 в 19:54
Я тоже страдал от этой проблемы.
Как сказал Paulw11, проблема заключается в вызове метода вашего класса регистра.
Я следовал учебнику по обновлению и заставил таблицу работать так:
var tableView = tableViewController.tableView tableView.registerClass(UITableViewController.self, forHeaderFooterViewReuseIdentifier: cellIdentifier)
var refreshControl = UIRefreshControl() refreshControl.addTarget(self, action: Selector("sortArray"), forControlEvents: UIControlEvents.ValueChanged) self.refreshControl = refreshControl . func sortArray()
включив обновление и разрешение на запуск моего кода.
Debugging Error: Thread 1: signal SIGABRT
You’re now watching this thread. If you’ve opted in to email or web notifications, you’ll be notified when there’s activity. Click again to stop watching or visit your profile to manage watched threads and notifications.
You’ve stopped watching this thread and will no longer receive emails or web notifications when there’s activity. Click again to start watching.
Hello, I’ve been trying to find away past the error I’m getting on my xcode project the last few days. I know generally the error «Thread 1: signal SIGABRT» is caused by missing code after you link a button or something from deleting it, but I don’t think this is the same case considering the code doesn’t have anything linked. I’ve done a lot of Googling and YouTubing, but I can’t seem to find the problem. On line 54 under MenuController.swift i get the error «Thread 1: signal SIGABRT».
/ let cell = tableView.dequeueReusableCell(withIdentifier: "MenuCell") as! MenuCell
I will link the project and images. I’m not sure why it’s doing it, but anything will help. Thank you so much.
Post not yet marked as solved Up vote post of Studio228 Down vote post of Studio228
Copy to clipboard
Share this post
Copied to Clipboard
Apple Recommended
>> generally the error «Thread 1: signal SIGABRT» is caused by missing code
Not really. A signal is just really a way that an application can tell the underlying Unix kernel that something important happened (that’s what «signal» really means), but it’s usually something bad, and usually represents a crash. The SIGABRT signal specifically indicates that your app called the «abort()» function, which is how apps crash themselves intentionally.
The key to understanding a SIGABRT, therefore, is the error message displayed as part of the abort. In your case, you show this message in your second linked image. The «as!» operator triggered the abort because it the type of the dequeued table cell wasn’t MenuCell as you wanted, but was just a plain ol’ UITableViewCell.
The most likely reason for this is in your storyboard. You have defined a custom table cell, and given it the «MenuCell» identifier, but you haven’t changed its class from the default UITableViewCell to MenuCell (which apparently is a class as well as a cell identifier). To change it:
— Select the cell in your storyboard.
— In the Identity inspector on the right (Command-Option-3), enter «MenuCell» for the class. If this class is actually defined in the SlideMenuControllerSwift framework, make sure Xcode shows the correct module name in the second field.
Thread 1: signal SIGABRT при запуске на реальном iPhone?
Соответственно проблема такая, запускаю на iPhone проект (самый простой, кнопка привязанная к лайблу и текстарее), выдает лог ниже, и указывает на строку главного класса с припиской Thread 1: signal SIGABRT (на эмуляторе вообще ошибка спрингборда, да и не с моей мощностью им пользоваться):
return UIApplicationMain(argc, argv, nil, NSStringFromClass([mnpAppDelegate class]));
2013-12-26 19:47:17.993 FirstAction[6026:60b] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key _myField.' *** First throw call stack: (0x2e22ce83 0x385896c7 0x2e22cb89 0x2eb6c3b7 0x2eb7dffd 0x2e19c7e9 0x30d104df 0x30c720fb 0x30ad3b59 0x309b579d 0x309b5719 0x309bc3f1 0x309b9ae5 0x30a2482d 0x30a215fd 0x30a1bb41 0x309b6a07 0x309b5cfd 0x30a1b321 0x32e9b76d 0x32e9b357 0x2e1f7777 0x2e1f7713 0x2e1f5edf 0x2e160471 0x2e160253 0x30a1a5c3 0x30a15845 0x9d275 0x38a82ab7) libc++abi.dylib: terminating with uncaught exception of type NSException (lldb)
- Вопрос задан более трёх лет назад
- 9931 просмотр
Как исправить ошибку в XCode (Thread 1: SIGABRT)?
«Thread 1: signal SIGABRT» и приложение даже не открывается (что в общем то не странно).
Приложение для расчета индекса массы тела. Окна задал, связь с ними задал.
// // FirstViewController.swift // Mass App // // Created by *** on 30.08.16. // Copyright © 2016 ***. All rights reserved. // import UIKit class FirstViewController: UIViewController < @IBOutlet weak var ageTextField: UITextField! @IBOutlet weak var heightTextField: UITextField! @IBOutlet weak var weightTextField: UITextField! @IBOutlet weak var sexSegmentedControl: UISegmentedControl! @IBOutlet weak var activitySegmentedControl: UISegmentedControl! @IBOutlet weak var resultsLabel: UILabel! @IBAction func calculateTapped(sender: AnyObject) < weak var activitySegmentedControl: UISegmentedControl! func calculateTapped(sender: AnyObject) < var bmr: Double = 0 var bmi: Double = 0 if let age = Int(ageTextField.text!) < if let height = Int(heightTextField.text!) < if let weight = Int(weightTextField.text!) < switch sexSegmentedControl.selectedSegmentIndex < case 0: bmr = 88.362 + 13.397 * Double(weight) + 4.799 * Double(height) - 5.677 * Double(age) case 1: bmr = 447.593 + 9.247 * Double(weight) + 3.098 * Double(height) - 4.330 * Double(age) default: bmr = 0 >bmi = Double(weight) / pow(Double(height) / 100, 2) > > > let factor = [1.375, 1.55, 1.725, 1.9] let selectedFactor = factor[activitySegmentedControl.selectedSegmentIndex] bmr *= selectedFactor resultsLabel.text? = "Вы должны потреблять \(Int(bmr)) килокалорий для поддержания веса.\nИндекс массы тела \(Int(bmi))." UIApplication.sharedApplication().keyWindow!.endEditing(true) > > 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. >>
2016-08-30 19:05:45.409 Mass App[4618:118258] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key activityTextField.'
Предполагаю что ошибка в том что я до этого вместо activitySegmentedControl писал activityTextField.
Где то это осталось и не дает запуску? Или что.
- Вопрос задан более трёх лет назад
- 4982 просмотра
1 комментарий
Оценить 1 комментарий