gpt4 book ai didi

ios - pushViewController 崩溃

转载 作者:行者123 更新时间:2023-11-28 09:05:41 25 4
gpt4 key购买 nike

我正在尝试推送 ViewController,但我的应用程序每次都会崩溃。

我正在使用 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)

关于我做错了什么,你有什么建议吗?

这是我的 Storyboard的样子: enter image description here

堆栈跟踪: enter image description here

最佳答案

我猜你的 navigationControllernil。使用 ! 强制它解包将导致崩溃。确保 navigationController 不是 nil

关于ios - pushViewController 崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30844243/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com