ios - Swift 1.2: fatal error: unexpectedly found nil while unwrapping an Optional value -
i wanted click picture , display on uiimageview.
i had defined needed outlets , actions , here code.
but shows error.
class viewcontroller: uiviewcontroller, uiimagepickercontrollerdelegate, uinavigationcontrollerdelegate { @iboutlet weak var camera: uibutton! @iboutlet weak var gallery: uibutton! @iboutlet weak var viewimage: uiimageview! @ibaction func photogalleryaction(sender: uibutton) { let picker = uiimagepickercontroller() picker.delegate = self picker.sourcetype = .photolibrary presentviewcontroller(picker, animated: true, completion: nil) } func imagepickercontroller(picker: uiimagepickercontroller, didfinishpickingmediawithinfo info: [string : anyobject]) { viewimage.image = info[uiimagepickercontrolleroriginalimage] as? uiimage dismissviewcontrolleranimated(true, completion: nil) } }
here error:
fatal error: unexpectedly found nil while unwrapping optional value
you have check connections between storyboard , code. if connected it, may corrupted using old storyboard file or else (it happens when using assitant editor)
Comments
Post a Comment