我在我的 VC 中使用自定义圆形动画来连接到一个新的 VC,它工作正常,这就是代码
override func prepare(for segue: UIStoryboardSegue, sender: Any?)
{
let secondVC = segue.destination as! SecondViewController
secondVC.transitioningDelegate = self
secondVC.modalPresentationStyle = .custom
}
但是当我使用同一个 VC 上的另一个按钮转至另一个 VC 时,我收到一条错误消息,提示 Could not cast value of type 'I_Need.ReminderTableViewController' (0x1020e6e98) to 'I_Need.SecondViewController (0x1020e6a08) .
最佳答案
你需要做if let
而不是let
,因为你的另一个VC不是SecondViewController
类型:
if let secondVC = segue.destination as? SecondViewController{
secondVC.transitioningDelegate = self
secondVC.modalPresentationStyle = .custom
}
关于ios - 链接两个 ViewController 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42770276/