我收到一个错误,以 NSException (lldb) 类型的未捕获异常终止。错误就是错误
回溯是
2017-06-11 22:10:04.009 Kenshin_Swift[6073:541383] Unknown class PhotoController in Interface Builder file.
2017-06-11 22:10:04.120 Kenshin_Swift[6073:541383] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIViewController 0x7fe830f06900> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key PhotoSelect.'
*** First throw call stack:
(
0 CoreFoundation 0x00000001068efd4b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x000000010635821e objc_exception_throw + 48
2 CoreFoundation 0x00000001068efc99 -[NSException raise] + 9
3 Foundation 0x0000000105c919df -[NSObject(NSKeyValueCoding) setValue:forKey:] + 291
4 UIKit 0x0000000106eae293 -[UIViewController setValue:forKey:] + 88
5 UIKit 0x000000010712279e -[UIRuntimeOutletConnection connect] + 109
6 CoreFoundation 0x00000001068949e0 -[NSArray makeObjectsPerformSelector:] + 256
7 UIKit 0x0000000107121122 -[UINib instantiateWithOwner:options:] + 1867
8 UIKit 0x0000000106eb49c5 -[UIViewController _loadViewFromNibNamed:bundle:] + 386
9 UIKit 0x0000000106eb52e7 -[UIViewController loadView] + 177
10 UIKit 0x0000000106eb561c -[UIViewController loadViewIfRequired] + 201
11 UIKit 0x0000000106eb5e70 -[UIViewController view] + 27
12 UIKit 0x0000000106f144f3 -[UITabBarController transitionFromViewController:toViewController:transition:shouldSetSelected:] + 483
13 UIKit 0x0000000106f13935 -[UITabBarController transitionFromViewController:toViewController:] + 59
14 UIKit 0x0000000106f0f7f6 -[UITabBarController _setSelectedViewController:] + 365
15 UIKit 0x0000000106f0f678 -[UITabBarController setSelectedViewController:] + 234
16 UIKit 0x0000000106dcd239 +[UIView(Animation) performWithoutAnimation:] + 90
17 UIKit 0x0000000106f09c14 -[UITabBarController _selectDefaultViewControllerIfNecessaryWithAppearanceTransitions:] + 354
18 UIKit 0x0000000106f0ad8e -[UITabBarController viewWillAppear:] + 206
19 UIKit 0x0000000106ebb96f -[UIViewController _setViewAppearState:isAnimating:] + 692
20 UIKit 0x0000000106ebc07f -[UIViewController __viewWillAppear:] + 147
21 UIKit 0x0000000106ebd873 -[UIViewController viewWillMoveToWindow:] + 507
22 UIKit 0x0000000106dc3a87 -[UIView(Hierarchy) _willMoveToWindow:withAncestorView:] + 621
23 UIKit 0x0000000106dd485b -[UIView(Internal) _addSubview:positioned:relativeTo:] + 451
24 UIKit 0x0000000106dc30d7 -[UIView(Hierarchy) addSubview:] + 838
25 UIKit 0x0000000106d7f7bf -[UIWindow addRootViewControllerViewIfPossible] + 849
26 UIKit 0x0000000106d7fc06 -[UIWindow _setHidden:forced:] + 293
27 UIKit 0x0000000106d93519 -[UIWindow makeKeyAndVisible] + 42
28 UIKit 0x0000000106d0bf8d -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 4818
29 UIKit 0x0000000106d120ed -[UIApplication _runWithMainScene:transitionContext:completion:] + 1731
30 UIKit 0x0000000106d0f26d -[UIApplication workspaceDidEndTransaction:] + 188
31 FrontBoardServices 0x000000010a55d6cb __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 24
32 FrontBoardServices 0x000000010a55d544 -[FBSSerialQueue _performNext] + 189
33 FrontBoardServices 0x000000010a55d8cd -[FBSSerialQueue _performNextFromRunLoopSource] + 45
34 CoreFoundation 0x0000000106894761 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
35 CoreFoundation 0x000000010687998c __CFRunLoopDoSources0 + 556
36 CoreFoundation 0x0000000106878e76 __CFRunLoopRun + 918
37 CoreFoundation 0x0000000106878884 CFRunLoopRunSpecific + 420
38 UIKit 0x0000000106d0daea -[UIApplication _run] + 434
39 UIKit 0x0000000106d13c68 UIApplicationMain + 159
40 Kenshin_Swift 0x0000000105b9f07f main + 111
41 libdyld.dylib 0x0000000109dc368d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
照片控制器是
import Foundation
import UIKit
class PhotoController:UIViewController,UINavigationControllerDelegate,UIImagePickerControllerDelegate{
@IBOutlet weak var myImageView: UIImageView!
@IBAction func PhotoSelect(_ sender: Any) {
}
@IBAction func PhotoSend(_ sender: Any) {
let myPickerController = UIImagePickerController()
myPickerController.delegate = self;
myPickerController.sourceType = UIImagePickerControllerSourceType.photoLibrary
self.present(myPickerController, animated: true, completion: nil)
}
func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : AnyObject])
{
myImageView.image = info[UIImagePickerControllerOriginalImage] as? UIImage
self.dismiss(animated: true, completion: nil)
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
//myImageUploadRequest()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
插座就是插座
我阅读了为什么会发生此错误消息。它说当“插座”错误时,会发生此错误。但我不知道如何解决此问题。我看到 PhotoSelect&PhotoSend 的插座有!,但我不明白这是什么意思。我该怎么办?
问题是两个插座PhotoSelect
和PhotoSend
。您可能不小心将这些创建为@IBOutlet
、删除了它们并重新创建为@IBAction
。
看看他们!
旁边有一个。这意味着这些插座不再连接。所以当你运行你的应用程序时,你的故事板在你的视图控制器中找不到这些插座,所以它崩溃了。
您需要通过单击 删除这些插座x
。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句