当我尝试选择"检查"我的应用程序崩溃了选项卡我有一切联系我不知道为什么我得到这个错误。有人能伸出援助之手吗?下面是我的InspectionViewController和我的错误代码。
InspectionVC:
//
// InspectionVC.swift
// Chat
//
// Created by Wiiliam Pettit on 6/2/17.
// Copyright © 2017 MVI. All rights reserved.
//
import UIKit
class InspectionVC: UIViewController, UIPickerViewDelegate, UIPickerViewDataSource {
@IBOutlet weak var picker: UIPickerView!
var pickerData: [String] = [String]()
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
// Connect data:
self.picker.delegate = self
self.picker.dataSource = self
// Input data into the Array:
pickerData = ["5312", "5387", "53C4", "53W5", "53W8", "5349"]
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func numberOfComponents(in pickerView: UIPickerView) -> Int {
return 1
}
func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {
return pickerData.count
}
func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? {
return pickerData[row]
}
// Catpure the picker view selection
func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {
if(row == 0)
{
UIApplication.shared.open(URL(string: "http://mvi.crompco.com/Module_Inspect/perform/22243/230")!)
}
else if(row == 1)
{
UIApplication.shared.open(URL(string: "http://mvi.crompco.com")!)
}
else if(row == 2)
{
UIApplication.shared.open(URL(string: "http://mvi.crompco.com")!)
}
else if(row == 3)
{
UIApplication.shared.open(URL(string: "http://mvi.crompco.com")!)
}
else if(row == 4)
{
UIApplication.shared.open(URL(string: "http://mvi.crompco.com")!)
}
else if(row == 5)
{
UIApplication.shared.open(URL(string: "http://mvi.crompco.com")!)
}
}
}
错误:
Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<QuickChat.InspectionVC 0x7fe83ad275f0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key pickerView.'
*** First throw call stack:
(
0 CoreFoundation 0x000000010d443b0b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x000000010c545141 objc_exception_throw + 48
2 CoreFoundation 0x000000010d443a59 -[NSException raise] + 9
3 Foundation 0x000000010c05ae8b -[NSObject(NSKeyValueCoding) setValue:forKey:] + 292
4 UIKit 0x000000010e369644 -[UIViewController setValue:forKey:] + 87
5 UIKit 0x000000010e5d66b9 -[UIRuntimeOutletConnection connect] + 109
6 CoreFoundation 0x000000010d3e9e8d -[NSArray makeObjectsPerformSelector:] + 269
7 UIKit 0x000000010e5d506f -[UINib instantiateWithOwner:options:] + 1856
8 UIKit 0x000000010e36fc73 -[UIViewController _loadViewFromNibNamed:bundle:] + 381
9 UIKit 0x000000010e370589 -[UIViewController loadView] + 177
10 UIKit 0x000000010e3708ba -[UIViewController loadViewIfRequired] + 195
11 UIKit 0x000000010e37110a -[UIViewController view] + 27
12 UIKit 0x000000010e3cd40b -[UITabBarController transitionFromViewController:toViewController:transition:shouldSetSelected:] + 476
13 UIKit 0x000000010e3cc89c -[UITabBarController transitionFromViewController:toViewController:] + 59
14 UIKit 0x000000010e3c89d6 -[UITabBarController _setSelectedViewController:] + 410
15 UIKit 0x000000010e3c87a5 -[UITabBarController setSelectedViewController:] + 109
16 UIKit 0x000000010e3cc741 -[UITabBarController _tabBarItemClicked:] + 384
17 UIKit 0x000000010e1cfd22 -[UIApplication sendAction:to:from:forEvent:] + 83
18 UIKit 0x000000010e5e26f7 -[UITabBar _sendAction:withEvent:] + 566
19 UIKit 0x000000010e1cfd22 -[UIApplication sendAction:to:from:forEvent:] + 83
20 UIKit 0x000000010e35425c -[UIControl sendAction:to:forEvent:] + 67
21 UIKit 0x000000010e354577 -[UIControl _sendActionsForEvents:withEvent:] + 450
22 UIKit 0x000000010e5e4db5 -[UITabBar _buttonUp:] + 113
23 UIKit 0x000000010e1cfd22 -[UIApplication sendAction:to:from:forEvent:] + 83
24 UIKit 0x000000010e35425c -[UIControl sendAction:to:forEvent:] + 67
25 UIKit 0x000000010e354577 -[UIControl _sendActionsForEvents:withEvent:] + 450
26 UIKit 0x000000010e3534b2 -[UIControl touchesEnded:withEvent:] + 618
27 UIKit 0x000000010e23d49a -[UIWindow _sendTouchesForEvent:] + 2707
28 UIKit 0x000000010e23ebb0 -[UIWindow sendEvent:] + 4114
29 UIKit 0x000000010e1eb7b0 -[UIApplication sendEvent:] + 352
30 UIKit 0x000000010e9ceadc __dispatchPreprocessedEventFromEventQueue + 2926
31 UIKit 0x000000010e9c6a3a __handleEventQueue + 1122
32 CoreFoundation 0x000000010d3e9c01 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
33 CoreFoundation 0x000000010d3cf0cf __CFRunLoopDoSources0 + 527
34 CoreFoundation 0x000000010d3ce5ff __CFRunLoopRun + 911
35 CoreFoundation 0x000000010d3ce016 CFRunLoopRunSpecific + 406
36 GraphicsServices 0x000000011156ea24 GSEventRunModal + 62
37 UIKit 0x000000010e1ce0d4 UIApplicationMain + 159
38 QuickChat 0x000000010a83fba7 main + 55
39 libdyld.dylib 0x00000001104ae65d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
答案 0 :(得分:0)
选择器的引用插座已设置&#34; pickerView&#34;而不是&#34;选择器&#34;。
答案 1 :(得分:0)