現在、Xcodeを通じてiPhone用のフィットネスアプリを作成しています。それは3つの異なるビューコントローラとそれぞれに添付されたファイルを持っています。私は現在、2番目のファイルで2番目のView Controllerで作業しています。現在、4つのIBアウトレットをコードに追加し、ボタンのIBアクションを追加しました。しかし、コードを実行すると、シミュレータでフリーズし、AppDelegateクラスの画面に戻ってきて、Signal Sigabrtという赤い領域が表示されます。アウトレットとアクションをすべて削除すると、プログラムは正常に動作し、すべてが正常に動作しますが、コンセントを1つでも追加すると、シミュレータが再びフリーズし、Signal Sigabrtが再び戻ってきます。私は他の多くの記事をオンラインで読んでいます。これは、要素とアウトレットとアクションの接続に問題があるためです。そのため、Connections Inspectorでアクションとアウトレットを削除し、すべてを再接続しました。しかし、これは何も解決しなかったし、私はまだ同じシグナルSigabrtの問題に固執しています。私はデバッガが私に与えてくれたものを見て、Breakfast1
コンセントが間違っていると言います。そのため、コンセントのインスペクタでコンセントを取り外してプログラムを再度実行しましたが、次のコンセントが間違っていることを伝え続けます信号Sigabrt再び私。他の誰かがこの問題を抱えていて、それを解決するのに役立つでしょうか?IBアウトレットとエラーの原因となるアクションスレッド1:Signal Sigabrt
マイViewController2コード:デバッグ面積が私を与えている何
import UIKit
class ViewController2: UIViewController {
@IBOutlet weak var Breakfast1: UITextField!
@IBOutlet weak var Lunch1: UITextField!
@IBOutlet weak var Dinner1: UITextField!
@IBOutlet weak var Total1: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
/
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
/
}
@IBAction func addingButton(_ sender: Any) {
}
}
:
2017-12-28 14:06:03.645843-0700 Fitness App FBLA[96716:47605553] Unknown class ViewController2 in Interface Builder file.
2017-12-28 14:06:03.658340-0700 Fitness App FBLA[96716:47605553] [MC] Lazy loading NSBundle MobileCoreServices.framework
2017-12-28 14:06:03.659452-0700 Fitness App FBLA[96716:47605553] [MC] Loaded MobileCoreServices.framework
2017-12-28 14:06:03.692388-0700 Fitness App FBLA[96716:47605553] [MC] System group container for systemgroup.com.apple.configurationprofiles path is /Users/basketballboy03/Library/Developer/CoreSimulator/Devices/8342977F-88AA-474E-BDEB-EAABE8007D1C/data/Containers/Shared/SystemGroup/systemgroup.com.apple.configurationprofiles
2017-12-28 14:06:03.749797-0700 Fitness App FBLA[96716:47605553] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIViewController 0x7fa6e3417c40> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key Breakfast1.'
*** First throw call stack:
(
0 CoreFoundation 0x000000010cd4b1ab __exceptionPreprocess + 171
1 libobjc.A.dylib 0x00000001090f3f41 objc_exception_throw + 48
2 CoreFoundation 0x000000010cd4b0f9 -[NSException raise] + 9
3 Foundation 0x0000000108b161e3 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 292
4 UIKit 0x0000000109b2d777 -[UIViewController setValue:forKey:] + 87
5 UIKit 0x0000000109e1ccb1 -[UIRuntimeOutletConnection connect] + 109
6 CoreFoundation 0x000000010ccee4fd -[NSArray makeObjectsPerformSelector:] + 317
7 UIKit 0x0000000109e1b667 -[UINib instantiateWithOwner:options:] + 1856
8 UIKit 0x0000000109b34838 -[UIViewController _loadViewFromNibNamed:bundle:] + 383
9 UIKit 0x0000000109b35164 -[UIViewController loadView] + 177
10 UIKit 0x0000000109b35495 -[UIViewController loadViewIfRequired] + 195
11 UIKit 0x0000000109b35cf2 -[UIViewController view] + 27
12 UIKit 0x000000010a5c53a9 -[_UIFullscreenPresentationController _setPresentedViewController:] + 89
13 UIKit 0x0000000109b03ba7 -[UIPresentationController initWithPresentedViewController:presentingViewController:] + 133
14 UIKit 0x0000000109b48f6a -[UIViewController _presentViewController:withAnimationController:completion:] + 3808
15 UIKit 0x0000000109b4bdad __63-[UIViewController _presentViewController:animated:completion:]_block_invoke + 99
16 UIKit 0x0000000109b4c47d -[UIViewController _performCoordinatedPresentOrDismiss:animated:] + 532
17 UIKit 0x0000000109b4bd0c -[UIViewController _presentViewController:animated:completion:] + 181
18 UIKit 0x0000000109b4c06b -[UIViewController presentViewController:animated:completion:] + 159
19 UIKit 0x000000010a297cbc __74-[UIStoryboardPresentationSegueTemplate newDefaultPerformHandlerForSegue:]_block_invoke + 133
20 UIKit 0x000000010a2b7dcb -[UIStoryboardSegueTemplate _performWithDestinationViewController:sender:] + 279
21 UIKit 0x000000010a2b7c83 -[UIStoryboardSegueTemplate _perform:] + 82
22 UIKit 0x000000010a2b7f4b -[UIStoryboardSegueTemplate perform:] + 157
23 UIKit 0x0000000109992275 -[UIApplication sendAction:to:from:forEvent:] + 83
24 UIKit 0x0000000109b0f4a2 -[UIControl sendAction:to:forEvent:] + 67
25 UIKit 0x0000000109b0f7bf -[UIControl _sendActionsForEvents:withEvent:] + 450
26 UIKit 0x0000000109b0e6ec -[UIControl touchesEnded:withEvent:] + 618
27 UIKit 0x0000000109a07bbb -[UIWindow _sendTouchesForEvent:] + 2807
28 UIKit 0x0000000109a092de -[UIWindow sendEvent:] + 4124
29 UIKit 0x00000001099ace36 -[UIApplication sendEvent:] + 352
30 UIKit 0x000000010a2ef434 __dispatchPreprocessedEventFromEventQueue + 2809
31 UIKit 0x000000010a2f2089 __handleEventQueueInternal + 5957
32 CoreFoundation 0x000000010ccee231 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
33 CoreFoundation 0x000000010cd8de41 __CFRunLoopDoSource0 + 81
34 CoreFoundation 0x000000010ccd2b49 __CFRunLoopDoSources0 + 185
35 CoreFoundation 0x000000010ccd212f __CFRunLoopRun + 1279
36 CoreFoundation 0x000000010ccd19b9 CFRunLoopRunSpecific + 409
37 GraphicsServices 0x000000010f4b39c6 GSEventRunModal + 62
38 UIKit 0x00000001099905e8 UIApplicationMain + 159
39 Fitness App FBLA 0x00000001087dcbf7 main + 55
40 libdyld.dylib 0x000000010de77d81 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
最も重要なメッセージは、Interface Builderのクラスを認識していないことを意味し、Interface Builderのファイル*に*不明なクラスViewController2です。 – vadian
私は複数のView Controllerを使用する方法をオンラインで見ていましたが、2つのコントローラをさらにドラッグして2つのファイルをそれらに接続して、コードを書くことができました。 –