Udacity로 Xcode를 배우고 있습니다. 예외 오류로 인해 문제가 발생했습니다. 여기 내 ViewController.swift 문서가 있습니다.
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var recordingLabel: UILabel!
@IBOutlet weak var recordButton: UIButton!
@IBOutlet weak var stopRecordingButton: UIButton!
func buttonAction(sender:UIButton){
}
override func viewDidLoad() {
super.viewDidLoad()
stopRecordingButton.isEnabled = false
// Do any additional setup after loading the view.
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
print("viewWillAppear called")
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// depose of any resources that can be recreated
}
@IBAction func recordAudio(_ sender: AnyObject){
recordingLabel.text = "Recording in Progress"
stopRecordingButton.isEnabled = true
recordButton.isEnabled = false
}
@IBAction func stopRecording(_ sender: AnyObject) {
recordButton.isEnabled = true
stopRecordingButton.isEnabled = false
recordingLabel.text = "Tap to record"
}
}
그리고 여기 내 AppDelegate.swift가 있습니다.
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true
}
// MARK: UISceneSession Lifecycle
func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
// Called when a new scene session is being created.
// Use this method to select a configuration to create the new scene with.
return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
}
func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
// Called when the user discards a scene session.
// If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
// Use this method to release any resources that were specific to the discarded scenes, as they will not return.
}
}
내 오류 메시지는 다음과 같습니다. Thread 1 : Exception : "-[SingingScope_Storyboard.ViewController recordButton :] : unrecognized selector sent to instance 0x7fb12cc088c0"
이것을 디버그하려면 어떻게해야합니까? 감사합니다!
스토리 보드를 통해 선택기 (이벤트에 연결된 함수)를 추가 한 다음 코드에서 변경하여 스토리 보드가 동기화되지 않는 경우 이러한 문제가 발생할 수 있습니다.
에 연결 buttonAction(sender:UIButton)
을 시도한다고 가정 recordButton
하고 다음을 시도하십시오.
@IBAction func buttonAction(sender: UIButton)
그래도 문제가 해결되지 않으면 스토리 보드 연결의 스크린 샷을 제공해 주시면 더 많은 도움을 드리겠습니다!
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다