2017-06-08 110 views
0

当我尝试选择“检查”选项卡我的一切联系林不知道为什么我收到这个错误我的应用程序崩溃。有人能帮忙吗?以下是我的InspectionViewController和我的错误代码。TabView的崩溃时选择

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) 
+1

您已经设置ibloutlet,然后从类中删除,但通过厦门国际银行文件不解除绑定 –

+0

确保你没有在您的视图控制器中的另一个链接对pickerView不存在的IBOutlet中。 – Vlad

+1

@William您先前已经采取了“pickerView”因为这似乎是改变“选择器”。所以,你需要解除绑定和绑定“装载机”正确IBOutlet中一个IBOutlet中。 –

回答

0

为拾取您的引用插座设置 “pickerView” 而不是 “选择器”。

  1. 转到故事板并选择视图控制器上的选取器视图。
  2. 选择“显示所有连接检查”在公用事业 部分(Xcode中的右选项卡)。
  3. 删除引用连接到 “pickerView” 插座。
  4. 添加引用出口“选择器”。
0

除'picker'(UIPickerView的IBOutlet)外,在连接检查器中还有一个出口连接。

打开您的连接检查器并删除与'pickerView'实例的连接。

Steps: Select Storyboard >> Select View Controller >> Open Connection Inspector >> Check all IBOutlet connections and find 'pickerView' >> Remove connection of 'pickerView'

enter image description here