我正在尝试制作相机应用程序。
当我尝试跑步时,我得到了这个帖子:
thread1:信号SIGABRT
在以下代码中。
class AppDelegate: UIResponder, UIApplicationDelegate {}
这只是我使用的viewcontroller类:
import UIKit
class ViewController: UIViewController, UIImagePickerControllerDelegate, UINavigationControllerDelegate {
@IBAction func takePicture(sender: UIButton) {
if (UIImagePickerController.isSourceTypeAvailable(.Camera)) {
if UIImagePickerController.availableCaptureModesForCameraDevice(.Rear) != nil {
imagePicker.allowsEditing = false
imagePicker.sourceType = .Camera
imagePicker.cameraCaptureMode = .Photo
presentViewController(imagePicker, animated: true, completion: {})
} else {
print("Rear camera doesn't exist")
}
} else {
print("Camera inaccessable")
}
}
@IBOutlet weak var currentImage: UIImageView!
let imagePicker: UIImagePickerController! = UIImagePickerController()
func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : AnyObject]) {
print("Got an image")
if let pickedImage:UIImage = (info[UIImagePickerControllerOriginalImage]) as? UIImage {
let selectorToCall = Selector("imageWasSavedSuccessfully:didFinishSavingWithError:context:")
UIImageWriteToSavedPhotosAlbum(pickedImage, self, selectorToCall, nil)
}
imagePicker.dismissViewControllerAnimated(true, completion: {
// Anything you want to happen when the user saves an image
})
}
func imagePickerControllerDidCancel(picker: UIImagePickerController) {
print("User canceled image")
dismissViewControllerAnimated(true, completion: {
// Anything you want to happen when the user selects cancel
})
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
imagePicker.delegate = self
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
有谁知道造成这种情况的原因是什么?