问题
'DrinkTransitioningDelegate' 中的委托函数未被调用。在演示过程中以及之后,'td'实例仍然存在于内存中。
class PresentingViewController: UIViewController {
let td = DrinkTransitioningDelegate()
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let item = inventory.beverages[indexPath.row]
item.isSelected = true
let controller = DrinkViewController(item: item)
controller.delegate = self
controller.transitioningDelegate = td
controller.modalPresentationStyle = .custom
//let navCon = UINavigationController(rootViewController: controller)
//navCon.transitioningDelegate = td
//navCon.modalPresentationStyle = .custom
present(controller, animated: true)
}
}
class DrinkTransitioningDelegate: NSObject, UIViewControllerTransitioningDelegate {
func presentationControllerForPresentedViewController(presented: UIViewController, presentingViewController presenting: UIViewController!, sourceViewController source: UIViewController) -> UIPresentationController? {
return DrinkPresentationViewController(presentedViewController:presented, presenting: presenting)
}
let animationController = DrinkAnimatedTransition()
func animationControllerForPresentedController(presented: UIViewController, presentingController presenting: UIViewController, sourceController source: UIViewController) -> UIViewControllerAnimatedTransitioning? {
animationController.isPresentation = true
return animationController
}
func animationControllerForDismissedController(dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? {
animationController.isPresentation = false
return animationController
}
deinit {
print("adf")
}
}
历史
public func presentationController(forPresented presented: UIViewController, presenting: UIViewController?, source: UIViewController) -> UIPresentationController?
我是从一些示例代码中复制过来的。我记不清确切的措辞,但编译器没有识别出错误。 - jbm