我要这个。 vc1(performSegue to vc3) - > vc2(2秒)-dismiss - > vc3
我指的是这个。 https://stackoverflow.com/a/39824680/11094223
VC1 CameraViewController
func showVC3() {
performSegue(withIdentifier: "showPhoto_Segue", sender: nil)
}
@IBAction func cameraButton_TouchUpInside(_ sender: Any) {
let settings = AVCapturePhotoSettings()
photoOutput?.capturePhoto(with: settings, delegate: self)
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "showLoading_Segue" {
let loadVC = segue.destination as! showLoadingViewController
loadVC.delegate = self
}else if segue.identifier == "showPhoto_Segue" {
let previewVC = segue.destination as! PreviewViewController
previewVC.frameSet = frameSet
previewVC.frameImage = frameImage
previewVC.image = self.image
}
}
extension CameraViewController: AVCapturePhotoCaptureDelegate {
func photoOutput(_ output: AVCapturePhotoOutput, didFinishProcessingPhoto photo: AVCapturePhoto, error: Error?) {
if let imageData = photo.fileDataRepresentation() {
image = UIImage(data: imageData)
performSegue(withIdentifier: "showLoading_Segue", sender: nil)
}
}
}
vc2 showLoadingViewController
protocol VC2Delegate {
func showVC3()
}
var delegate: VC2Delegate?
override func viewDidLoad() {
super.viewDidLoad()
let time = DispatchTime.now() + .seconds(2)
DispatchQueue.main.asyncAfter(deadline: time) {
self.showPreview()
}
}
func showPreview(){
dismiss(animated: true, completion: nil)
if let _ = delegate {
delegate?.showVC3()
}
}
vc3 PreviewViewController
如果你这样做当从vc2移动到vc3时,vc1会出现一段时间,然后转到vc3。我想直接从vc2到vc3。(解雇)。不擅长英语。对不起
您遇到的问题是因为您正在动画解雇vc2。只需将其更改为:
dismiss(animated: false, completion: nil)
if let _ = delegate {
delegate?.showVC3()
}
showVC3的动画将像在vc2上显示一样播放。同时vc2将从堆栈中消失。