func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
let alert = SCLAlertView()
alert.addButton("A",target:self,selector: #selector(FirstViewController.firstButton))
alert.addButton("B",target:self,selector: #selector(FirstViewController.secondButton))
self.dismiss(animated: true, completion: {
alert.showSuccess(kSuccessTitle,subTitle: kSubtitle1)
// self.present(secondViewController,animated: true,completion: nil)
})
}
@objc func firstButton(info: [UIImagePickerController.InfoKey : Any])
{
let sb = UIStoryboard(name:"Main",bundle: Bundle.main)
let secondViewController = sb.instantiateViewController(withIdentifier: "view2") as! SecondViewController
secondViewController.infoFromViewOne = info[UIImagePickerController.InfoKey.editedImage] as? UIImage
secondViewController.flag = 0
self.present(secondViewController,animated: true,completion: nil)
}
@objc func secondButton()
{
let sb = UIStoryboard(name:"Main",bundle: Bundle.main)
let thirdViewcontroller = sb.instantiateViewController(withIdentifier: "SecondViewController") as! ViewController
self.present(thirdViewcontroller,animated: true,completion: nil)
}
This is my code, My desire result is that when I click the first button, the page jump to "SecondViewcontroller" and the image in the SecondViewcontroller's imageView is the photo I just select.
But now, after selecting the photo and click the first button, the app crashes at AppDelegate.swift, with an error message:
"libc++abi.dylib: terminating with uncaught exception of type NSException
"
What should I do to make it correct?