接收问题:无法投射 'UIViewController' 类型的值试图在 Xcode 上设置动画
Receiving issue: Could not cast value of type 'UIViewController' trying to animate on Xcode
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
let secondVC = segue.destination as! SettingsViewController //error is marked here
secondVC.transitioningDelegate = self
secondVC.modalPresentationStyle = .custom
}
func animationController(forPresented presented: UIViewController, presenting: UIViewController, source: UIViewController) -> UIViewControllerAnimatedTransitioning? {
transition.transitionMode = .present
transition.startingPoint = settingsButton.center
transition.circleColor = UIColor.white
return transition
}
func animationController(forDismissed dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? {
transition.transitionMode = .dismiss
transition.startingPoint = settingsButton.center
transition.circleColor = UIColor.white
return transition
}
我正在关注 this tutorial 使用 Swift 为我的 Xcode 应用程序 制作动画。我 运行 陷入我的 SettingsViewController 无法转换为 UIViewController 的错误。我检查了其他有同样错误的问题,但没有发现任何有用的东西。
我收到错误 - SIGABRT:无法将类型 'UIViewController' (0x7fff897a42b8) 的值转换为 'Healthify.SettingsViewController' (0x107cd6a98)
有谁知道我做错了什么或经历过类似的事情吗?
我发现了问题。我在 ViewController 中嵌入了一个 UiViewController,它正在将 UiViewController 类型转换为设置ViewController。
我不需要 UiViewController 所以我删除了它,错误消失了。
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
let secondVC = segue.destination as! SettingsViewController //error is marked here
secondVC.transitioningDelegate = self
secondVC.modalPresentationStyle = .custom
}
func animationController(forPresented presented: UIViewController, presenting: UIViewController, source: UIViewController) -> UIViewControllerAnimatedTransitioning? {
transition.transitionMode = .present
transition.startingPoint = settingsButton.center
transition.circleColor = UIColor.white
return transition
}
func animationController(forDismissed dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? {
transition.transitionMode = .dismiss
transition.startingPoint = settingsButton.center
transition.circleColor = UIColor.white
return transition
}
我正在关注 this tutorial 使用 Swift 为我的 Xcode 应用程序 制作动画。我 运行 陷入我的 SettingsViewController 无法转换为 UIViewController 的错误。我检查了其他有同样错误的问题,但没有发现任何有用的东西。
我收到错误 - SIGABRT:无法将类型 'UIViewController' (0x7fff897a42b8) 的值转换为 'Healthify.SettingsViewController' (0x107cd6a98)
有谁知道我做错了什么或经历过类似的事情吗?
我发现了问题。我在 ViewController 中嵌入了一个 UiViewController,它正在将 UiViewController 类型转换为设置ViewController。
我不需要 UiViewController 所以我删除了它,错误消失了。