Swift:更改段索引时的分段控制错误

时间:2017-10-17 21:39:29

标签: swift user-interface

今天早上开始使用Swift,所以除了熟悉基于C语言之外,不要在这里假设知识。此页面上有一些图像(向左箭头,向上箭头,向右箭头和一个点)。我试图创建一个隐藏它的视图,并使用分段控制器导航到它们被隐藏的位置。

@IBOutlet weak var larrow: UIImageView!
@IBOutlet weak var uarrow: UIImageView!
@IBOutlet weak var rarrow: UIImageView!
@IBOutlet weak var dot: UIImageView!
@IBOutlet weak var sliderControl: UISlider!
@IBOutlet weak var conceptVsMath: UISegmentedControl!

这是我将代码更改为隐藏的所有元素的代码(在第二种情况下)。

@IBAction func changeView(_ sender: UISegmentedControl) {
    switch conceptVsMath.selectedSegmentIndex{
    case 0:
        larrow.isHidden = false;
        uarrow.isHidden = false;
        rarrow.isHidden = false;
        dot.isHidden = false;
        sliderControl.isHidden = false;
    case 1:
        larrow.isHidden = true;
        uarrow.isHidden = true;
        rarrow.isHidden = true;
        dot.isHidden = true;
        sliderControl.isHidden = true;
    default:
        break;
    }
}

因此第一个视图正常显示,并且滑块执行它应该执行的所有操作。但是,当我切换到第二个按钮(或大小写)时,我收到错误:"以NSException类型的未捕获异常终止。"这是我的 outlet list

以上是完整的错误消息:

*** First throw call stack:
(
    0   CoreFoundation                      0x000000011234e1cb __exceptionPreprocess + 171
    1   libobjc.A.dylib                     0x000000010de6ef41 objc_exception_throw + 48
    2   CoreFoundation                      0x00000001123ce914 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
    3   UIKit                               0x000000010f1cd409 -[UIResponder doesNotRecognizeSelector:] + 295
    4   CoreFoundation                      0x00000001122d1178 ___forwarding___ + 1432
    5   CoreFoundation                      0x00000001122d0b58 _CF_forwarding_prep_0 + 120
    6   UIKit                               0x000000010ef9eec9 -[UIApplication sendAction:to:from:forEvent:] + 83
    7   UIKit                               0x000000010f11c1f6 -[UIControl sendAction:to:forEvent:] + 67
    8   UIKit                               0x000000010f11c513 -[UIControl _sendActionsForEvents:withEvent:] + 450
    9   UIKit                               0x0000000128bd05cf -[UISegmentedControlAccessibility sendActionsForControlEvents:] + 41
    10  UIKit                               0x000000010f1df667 -[UISegmentedControl _setSelectedSegmentIndex:notify:animate:] + 665
    11  UIKit                               0x000000010f1e1e15 -[UISegmentedControl touchesEnded:withEvent:] + 196
    12  UIKit                               0x000000010f014b1b -[UIWindow _sendTouchesForEvent:] + 2807
    13  UIKit                               0x000000010f01623e -[UIWindow sendEvent:] + 4124
    14  UIKit                               0x000000010efb9d96 -[UIApplication sendEvent:] + 352
    15  UIKit                               0x0000000128bbf5e3 -[UIApplicationAccessibility sendEvent:] + 85
    16  UIKit                               0x000000010f8fbfce __dispatchPreprocessedEventFromEventQueue + 2809
    17  UIKit                               0x000000010f8fec23 __handleEventQueueInternal + 5957
    18  CoreFoundation                      0x00000001122f12b1 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
    19  CoreFoundation                      0x0000000112390d31 __CFRunLoopDoSource0 + 81
    20  CoreFoundation                      0x00000001122d5c19 __CFRunLoopDoSources0 + 185
    21  CoreFoundation                      0x00000001122d51ff __CFRunLoopRun + 1279
    22  CoreFoundation                      0x00000001122d4a89 CFRunLoopRunSpecific + 409
    23  GraphicsServices                    0x0000000115ba69c6 GSEventRunModal + 62
    24  UIKit                               0x000000010ef9d23c UIApplicationMain + 159
    25  try3                                0x000000010d556017 main + 55
    26  libdyld.dylib                       0x0000000113479d81 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) 

0 个答案:

没有答案