gpt4 book ai didi

ios - 选中时 TabView 崩溃

转载 作者:行者123 更新时间:2023-11-28 08:08:24 25 4
gpt4 key购买 nike

当我尝试选择“检查”选项卡时,我的应用程序崩溃了 我已链接所有内容 我不确定为什么会收到此错误。有人可以帮忙吗?下面是我的 InspectionViewController 和我的错误代码。

检查VC:

//
// 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)

最佳答案

选择器的引用导出设置为“pickerView”而不是“picker”。

  1. 转到 Storyboard并在 View Controller 上选择选择器 View 。
  2. 在实用程序中选择“显示连接检查器”部分(xcode 的右侧选项卡)。
  3. 移除连接到的引用 socket “选择器 View ”。
  4. 将引用 socket 添加到“选择器”。

关于ios - 选中时 TabView 崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44433928/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com