ios - 对 <ViewController> 开始/结束外观转换的不平衡调用

标签 ios swift xcode swift3 unwind-segue

我得到错误:

"Unbalanced calls to begin/end appearance transitions for ”.

在我的应用程序中,您从 tableViewController 开始,如果您单击底部的照片图标,相机会弹出,当您拍摄照片时,您会通过 navigationController > 进入编辑viewController。从这里,如果您单击图像,您将被发送到预览 viewController

我的问题是,如果我在编辑现有项目时单击“新照片”,它工作正常,但如果我在我刚刚创建(但尚未保存)的项目上单击“新照片”,我会被一路发送回到最初的tableViewController

enter image description here

我的代码是这样的:

// Called when the user finishes taking a photo.
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {
    // The info dictionary contains multiple representations of the image, and this uses the original.
    image = info[UIImagePickerControllerOriginalImage] as? UIImage

    // Dismiss the picker.
    dismiss(animated: false, completion: nil)

    performSegue(withIdentifier: "unwindToExpenseView", sender: self)
}

在我编辑viewController

@IBAction func unwindToExpenseView(sender: UIStoryboardSegue) {
    if let ImagePreviewer = sender.source as? ImagePreviewViewController {
        photoImageView.image = ImagePreviewer.image
    }
}

最佳答案

尝试在 dismiss(animated:)completionperformSegue

self.dismiss(animated: false) { 
      performSegue(withIdentifier: "unwindToExpenseView", sender: self)
}

关于ios - 对 <ViewController> 开始/结束外观转换的不平衡调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40042835/

相关文章:

ios - Xcode 9 - 无法附加到框架单元测试的 pid

javascript - React Native AppRegistry 不是可调用模块

swift - 为什么navigationBar隐藏collectionView?

ios - Cocoapods:LoadError - 没有要加载的文件

swift - 如何同步调用CLGeocoder方法

ios - UITabBar Lifecycle 的方法不会从后台启动

ios - Spritekit 逐帧动画/性能问题

ios - 缩放后无法平移 UIScrollView

android - 您如何支持 Titanium 中不同平台的不同 View

ios - Xcode14.3 中带有参数 DSTROOT 的 xcodebuild 错误