线程1:信号Sigbart按钮错误



2016-12-29 11:03:12.874 Albhabet City 1[9872:259138] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<Albhabet_City_1.IntroViewController 0x7fcf8ec14d60> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key play.'
*** First throw call stack:
(
	0   CoreFoundation                      0x0000000103c69d4b __exceptionPreprocess + 171
	1   libobjc.A.dylib                     0x000000010336221e objc_exception_throw + 48
	2   CoreFoundation                      0x0000000103c69c99 -[NSException raise] + 9
	3   Foundation                          0x0000000102e709df -[NSObject(NSKeyValueCoding) setValue:forKey:] + 291
	4   UIKit                               0x0000000104228293 -[UIViewController setValue:forKey:] + 88
	5   UIKit                               0x000000010449c79e -[UIRuntimeOutletConnection connect] + 109
	6   CoreFoundation                      0x0000000103c0e9e0 -[NSArray makeObjectsPerformSelector:] + 256
	7   UIKit                               0x000000010449b122 -[UINib instantiateWithOwner:options:] + 1867
	8   UIKit                               0x000000010422e9c5 -[UIViewController _loadViewFromNibNamed:bundle:] + 386
	9   UIKit                               0x000000010422f2e7 -[UIViewController loadView] + 177
	10  UIKit                               0x000000010422f61c -[UIViewController loadViewIfRequired] + 201
	11  UIKit                               0x000000010422fe70 -[UIViewController view] + 27
	12  UIKit                               0x0000000104af06a4 -[_UIFullscreenPresentationController _setPresentedViewController:] + 87
	13  UIKit                               0x000000010420a702 -[UIPresentationController initWithPresentedViewController:presentingViewController:] + 141
	14  UIKit                               0x0000000104242e97 -[UIViewController _presentViewController:withAnimationController:completion:] + 3956
	15  UIKit                               0x000000010424626b -[UIViewController _performCoordinatedPresentOrDismiss:animated:] + 530
	16  UIKit                               0x0000000104245d51 -[UIViewController presentViewController:animated:completion:] + 179
	17  UIKit                               0x000000010424b41e -[UIViewController _showViewController:withAction:sender:] + 274
	18  UIKit                               0x0000000104708fcc __66-[UIStoryboardShowSegueTemplate newDefaultPerformHandlerForSegue:]_block_invoke + 134
	19  UIKit                               0x00000001048631dd -[UIStoryboardSegueTemplate _performWithDestinationViewController:sender:] + 447
	20  UIKit                               0x0000000104862fed -[UIStoryboardSegueTemplate _perform:] + 82
	21  UIKit                               0x00000001048632af -[UIStoryboardSegueTemplate perform:] + 156
	22  UIKit                               0x000000010408f8bc -[UIApplication sendAction:to:from:forEvent:] + 83
	23  UIKit                               0x0000000104215c38 -[UIControl sendAction:to:forEvent:] + 67
	24  UIKit                               0x0000000104215f51 -[UIControl _sendActionsForEvents:withEvent:] + 444
	25  UIKit                               0x0000000104214e4d -[UIControl touchesEnded:withEvent:] + 668
	26  UIKit                               0x00000001040fd545 -[UIWindow _sendTouchesForEvent:] + 2747
	27  UIKit                               0x00000001040fec33 -[UIWindow sendEvent:] + 4011
	28  UIKit                               0x00000001040ab9ab -[UIApplication sendEvent:] + 371
	29  UIKit                               0x000000010489872d __dispatchPreprocessedEventFromEventQueue + 3248
	30  UIKit                               0x0000000104891463 __handleEventQueue + 4879
	31  CoreFoundation                      0x0000000103c0e761 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
	32  CoreFoundation                      0x0000000103bf398c __CFRunLoopDoSources0 + 556
	33  CoreFoundation                      0x0000000103bf2e76 __CFRunLoopRun + 918
	34  CoreFoundation                      0x0000000103bf2884 CFRunLoopRunSpecific + 420
	35  GraphicsServices                    0x0000000109cc2a6f GSEventRunModal + 161
	36  UIKit                               0x000000010408dc68 UIApplicationMain + 159
	37  Albhabet City 1                     0x0000000102d7adbf main + 111
	38  libdyld.dylib                       0x000000010734868d start + 1
	39  ???                                 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) 
上面的页面是我收到的错误

import UIKit
import AVFoundation
class IntroViewController: UIViewController {
    var player:AVAudioPlayer = AVAudioPlayer()
    @IBAction func play(_ sender: Any)
    {
    player.play()
    }
    
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        
        // Do any additional setup after loading the view.
    }
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
        
        do
        {
            let audioPath = Bundle.main.path(forResource: "song", ofType: "mp3")
            try player = AVAudioPlayer(contentsOf: NSURL(fileURLWithPath: audioPath!) as URL)
            
            
        }
        catch
        {
            //error
        }
    
    }
    
    /*
    // MARK: - Navigation
    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */
}

这是我在手机模拟器上单击按钮时无法揭示自己的页面。

我正在制作一个具有多个场景的应用程序。每当我单击我的第一个按钮到模拟器上的另一个幻灯片时,它都会将我切换到" appdelegate.swift"one_answers"类应用程序委托..." ...失败的模拟器,

sigabrt错误通常会在IB和您的代码之间打破连接时发生。例如,也许如果您将操作连接从按钮与@IBAction进行了操作连接并删除它,那么它将导致sigabrt。如果删除按钮,则可以修复它,然后建立新的连接并重写代码。

这是您可以查看的链接:Sigabrt解释了!(一般解决方案)-YouTube

最新更新