Я пытаюсь нажать ViewController, но мое приложение падает каждый раз.Crash on pushViewController
Я использую UIImagePickerControllerDelegate, чтобы сделать снимок, и после того, как был сделан снимок, этот код работает:
func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [NSObject : AnyObject]) {
let pickedImage = info[UIImagePickerControllerEditedImage] as! UIImage
// Reset the cameraButton and Tabbar
self.cameraButton.setImage(UIImage(named: "camera-button"), forState: .Normal)
self.cameraButton.transform = CGAffineTransformMakeScale(1, 1)
self.tabBarController?.tabBar.alpha = 1
let realmImage = Image()
realmImage.imagedata = UIImageJPEGRepresentation(pickedImage, 1.0)
let birthmark = Birthmark()
//birthmark.imagesArray = RLMArray()
birthmark.imagesArray.addObject(realmImage)
birthmark.bodyPart = Birthmark.Bodypart.LeftArm
realm.beginWriteTransaction()
realm.addObject(birthmark)
realm.commitWriteTransaction()
self.dismissViewControllerAnimated(true, completion: nil)
let secondViewController = self.storyboard!.instantiateViewControllerWithIdentifier("ItemViewController") as! ItemViewController
secondViewController.existingItem = birthmark
navigationController!.presentViewController(secondViewController, animated: true, completion: nil)
}
Тем не менее, всегда падает на последней строке:
navigationController!.presentViewController(secondViewController, animated: true, completion: nil)
XCode говорит: EXC_BREAKPOINT (код = 1, подкод = 0x100489474)
Есть ли у вас какие-либо указания относительно того, что я делаю неправильно?
Вот что моя раскадровки выглядит следующим образом:
Трассировка стека:
Можете ли вы предоставить трассировку стека? –
Почему вы просите навигационный контроллер представить второй контроллер. Почему бы не использовать 'self.presentViewController'? –
Исключено исключение. Возобновите выполнение программы и дайте ей сбой, чтобы сообщение об ошибке было распечатано на консоль. – Sulthan