2017-06-08 58 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