Я довольно новичок в Xcode и Swift, и я столкнулся с ошибкой, которую не могу отладить на всю жизнь. Когда я запускаю приложение, я не могу нажать кнопку входа или регистрации, не получив ошибку «Тема 1: Исключение». Пожалуйста помоги!
Вот мой код для моего ViewController
import UIKit
import AVKit
class ViewController: UIViewController {
var videoPlayer:AVPlayer?
var videoPlayerLayer:AVPlayerLayer?
@IBOutlet weak var LoginButton: UIButton!
@IBOutlet weak var SignUpButton: UIButton!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
setUpElements()
}
override func viewWillAppear(_ animated: Bool) {
// Set up video in the background
setUpVideo()
}
func setUpElements() {
Utilities.styleFilledButton(SignUpButton)
Utilities.styleHollowButton(LoginButton)
}
func setUpVideo() {
// Get the path to the resource in the bundle
let bundlePath = Bundle.main.path(forResource: "grass", ofType: "mp4")
guard bundlePath != nil else {
return
}
// Create a URL from it
let url = URL(fileURLWithPath: bundlePath!)
// Create the video player item
let item = AVPlayerItem(url: url)
// Create the player
videoPlayer = AVPlayer(playerItem: item)
// Create the layer
videoPlayerLayer = AVPlayerLayer(player: videoPlayer!)
// Adjust the size and frame
videoPlayerLayer?.frame = CGRect(x:
-self.view.frame.size.width*1.5, y: 0, width:
self.view.frame.size.width*4, height:
self.view.frame.size.height)
view.layer.insertSublayer(videoPlayerLayer!, at: 0)
// Add it to the view and play it
videoPlayer?.playImmediately(atRate: 1)
}
@IBAction func LoginTapped(_ sender: Any) {
}
@IBAction func SignUpTapped(_ sender: Any) {
}
}
И ошибка, которую я получаю, заключается в том, что «происходит прерывание с необработанным исключением типа NSException», когда я нажимаю кнопку входа в систему, а затем поток 1 : сигнал SIGABART в строке 14 моего AppDelegate рядом с классом APPDelegate: UIResponder, UIAPPlicationDelegate.
Код моего AppDelegate приведен ниже.
import UIKit
import Firebase
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
FirebaseApp.configure()
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.
}
}