在一个函数中以编程方式在彼此之上呈现两个 UIViewController
Present two UIViewControllers on top of each other programmatically in one function
我正在尝试展示 (1) ScrollViewController
,然后展示 (2) ImagePicker
。但是,只有 ScrollViewController
出现,后面的 ImagePicker
没有出现。
就个人而言,下面的代码工作正常,只是当一个跟随另一个时,它不起作用。我试过在完成处理程序中包含一个,仍然没有成功。
没有错误显示,除了,当序列发生时,Xcode 调试区域显示但完全空白,没有错误消息或警告。
问题:
What exactly is going on here that I'm missing? Why aren't both being presented? How can I ensure both the ScrollViewController
and ImagePicker
are displayed, one after the other?
(1) 滚动视图控制器:
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let vc = storyboard.instantiateViewControllerWithIdentifier("ScrollViewControllerID") as! ScrollViewController
self.presentViewController(vc, animated: true, completion: nil)
(2) ImagePicker:
let imagePicker = MyImagePickerController()
imagePicker.delegate = self
imagePicker.sourceType = .PhotoLibrary
imagePicker.allowsEditing = false
imagePicker.modalTransitionStyle = UIModalTransitionStyle.CoverVertical
self.presentViewController(imagePicker, animated: true, completion: nil)
一个视图控制器一次只能呈现一个控制器。事实上,有一个 属性: presentedViewController: UIViewController?
暗示了这一点。协调这些行动:
一个。仅展示来自您的基地 VC.
的 first VC
乙。在第一个演示调用的完成处理程序中,让 second VC 呈现最后一个位于顶部的:
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let vc = storyboard.instantiateViewControllerWithIdentifier("ScrollViewControllerID") as! ScrollViewController
self.presentViewController(vc, animated: true) {
let imagePicker = MyImagePickerController()
imagePicker.delegate = self
imagePicker.sourceType = .PhotoLibrary
imagePicker.allowsEditing = false
imagePicker.modalTransitionStyle = UIModalTransitionStyle.CoverVertical
vc.presentViewController(imagePicker, animated: true, completion: nil)
}
我正在尝试展示 (1) ScrollViewController
,然后展示 (2) ImagePicker
。但是,只有 ScrollViewController
出现,后面的 ImagePicker
没有出现。
就个人而言,下面的代码工作正常,只是当一个跟随另一个时,它不起作用。我试过在完成处理程序中包含一个,仍然没有成功。
没有错误显示,除了,当序列发生时,Xcode 调试区域显示但完全空白,没有错误消息或警告。
问题:
What exactly is going on here that I'm missing? Why aren't both being presented? How can I ensure both the
ScrollViewController
andImagePicker
are displayed, one after the other?
(1) 滚动视图控制器:
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let vc = storyboard.instantiateViewControllerWithIdentifier("ScrollViewControllerID") as! ScrollViewController
self.presentViewController(vc, animated: true, completion: nil)
(2) ImagePicker:
let imagePicker = MyImagePickerController()
imagePicker.delegate = self
imagePicker.sourceType = .PhotoLibrary
imagePicker.allowsEditing = false
imagePicker.modalTransitionStyle = UIModalTransitionStyle.CoverVertical
self.presentViewController(imagePicker, animated: true, completion: nil)
一个视图控制器一次只能呈现一个控制器。事实上,有一个 属性: presentedViewController: UIViewController?
暗示了这一点。协调这些行动:
一个。仅展示来自您的基地 VC.
的 first VC乙。在第一个演示调用的完成处理程序中,让 second VC 呈现最后一个位于顶部的:
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let vc = storyboard.instantiateViewControllerWithIdentifier("ScrollViewControllerID") as! ScrollViewController
self.presentViewController(vc, animated: true) {
let imagePicker = MyImagePickerController()
imagePicker.delegate = self
imagePicker.sourceType = .PhotoLibrary
imagePicker.allowsEditing = false
imagePicker.modalTransitionStyle = UIModalTransitionStyle.CoverVertical
vc.presentViewController(imagePicker, animated: true, completion: nil)
}