这是我的第一个问题,希望它不会太愚蠢。由于另一个呈现的视图没有完成,视图控制器不显示。
这里是我的应用程序:
VC1
VC2 - ChatTableViewController
VC3 - PopupPhotoSourceVC
VC1 - 一个按钮呈现VC2模态
VC2 - 一个 “栏” 按钮,模态呈现VC3 (VC3演示设置为“过电流上下文”)
VC2 - 设置展开顺序
@IBAction func unwindToChatTableViewController(segue: UIStoryboardSegue) {
attachPhotoButtonFinish()
}
VC3 - 中间的两个按钮,均设置为上方,通过拖动并使用StoryBoard进行选择来放松静止。
内VC3,使用SEGUE准备让VC2知道用户选择
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
let destChatViewController = segue.destination as! ChatTableViewController
if segue.identifier == "library" // library Button
{
print("set cameraType to library from popupviewcontroller")
let time = getCurrentTime()
print("==== timer start ====== \(time.3):\(time.4):\(time.5)")
destChatViewController.cameraType = "library"
}
else if segue.identifier == "newphoto" // newphoto Button
{
print("set cameraType to newphoto from popupviewcontroller")
let time = getCurrentTime()
print("==== timer start ====== \(time.3):\(time.4):\(time.5)")
destChatViewController.cameraType = "newphoto"
}
// for unwind segue, no need to call dismiss
print("not calling dismiss pop up")
let time = getCurrentTime()
print("==== timer start ====== \(time.3):\(time.4):\(time.5)")
//dismiss(animated: true, completion: nil)
}
里面VC2,attachPhotoButtonFinish将尝试根据用户的选择
func attachPhotoButtonFinish() {
print("attachphotobutton start")
let time = getCurrentTime()
print("==== timer start ====== \(time.3):\(time.4):\(time.5)")
let image = UIImagePickerController()
image.delegate = self
if cameraType == "library"{
image.sourceType = UIImagePickerControllerSourceType.photoLibrary
}
else if cameraType == "newphoto"{
image.sourceType = UIImagePickerControllerSourceType.camera
image.cameraCaptureMode = .photo
}
else{
print("Something wrong!!!")
return
}
image.allowsEditing = false
image.modalPresentationStyle = .overCurrentContext
print("calling imagepicker")
let time1 = getCurrentTime()
print("==== timer start ====== \(time1.3):\(time1.4):\(time1.5)")
self.present(image, animated: true, completion: nil)
}
而且我也来调用图像选取器控制器尝试打印VC3的脱硝时间
deinit{
print("===== \(self.classForCoder.description()) be deinit")
let time = getCurrentTime()
print("==== timer start ====== \(time.3):\(time.4):\(time.5)")
}
关于运行结果,有时(1/10)VC3在VC2之前完成图像选择器。所以我可以看到它正确显示。
====定时器启动====== 18时34分58秒
没有要求解雇弹出
====定时器启动====== 18时34分58秒
放松到ChatTableViewController cameraType =库
====定时器启动====== 18时34分58秒
attachphotobutton开始
====定时器启动====== 18时34分58秒
来电图片选择器
====定时器启动====== 18:34:58
===== PhotoStreamSourceTest.PopupPhotoSourceVC is deinit
==== timer start ====== 18:34:59
2017-09-20 18:34:59.274464 + 0800 PhotoStreamSourceTest [14690:399530] [AXRun-PID]客户端请求取消挂起PID:14706名称:
2017-09-20 18:34:59.283271 + 0800 PhotoStreamSourceTest [14690:399463] [MC] systemgroup.com.apple.configurationprofiles路径的系统组容器是/Users/_/Library/Developer/CoreSimulator/Devices/54B3F249-2C6A-4C18-B2E1-C7271199A7CF/data/Containers/Shared/SystemGroup/systemgroup.com.apple.configurationprofiles
2017-09-20 18:34:59.284012 +0800 PhotoStreamSourceTest [14690:399463] [MC]从私人有效用户设置读取。
但大部分时间,我收到下面的结果和图像选择器不显示。
====定时器启动====== 18点35分48秒
没有要求解雇弹出
====定时器启动====== 18点35分48秒
放松到ChatTableViewController cameraType =库
====定时器启动====== 18时35分48秒
attachphotobutton开始
====定时器启动====== 18时35分48秒
来电图片选择器
====定时器启动====== 18:35:48
2017-09-20 18:35:48.967515 + 0800 PhotoStreamSourceTest [14690:400836] [AXRun-PID]客户端请求取消挂起PID:14706名称:
2017-09-20 18:35:49.049357 + 0800 PhotoStreamSourceTest [ 14690:399463]警告:正在进行演示时尝试呈现!
===== PhotoStreamSourceTest.PopupPhotoSourceVC被DEINIT
====定时器启动====== 18点35分49秒
谢谢!
看看这个[意义的警告“,而演示文稿正在进行!”](https://stackoverflow.com/a/17120065/4056108) – chirag90
@ chirag90感谢您的及时答复。我只是想知道是否放松继续不适合这种情况。确保在调用图像选择器之前关闭VC3是绝对的规则。 – Hungo
对不起,我只是在帮助警告 – chirag90