I am trying to learn some new iOS programming patterns. I have read a bunch about the UIViewController transitioning APIs added in iOS 7. They look cool but also feel pretty heavy for what seems like a simpler task.
Consider this use case: I have a custom container view controller that manages "slides". It holds an array of slide view controllers and the user can move forward and backward though them by tapping a button.
I can implement the transition for this as follows:
private func transitionToViewController(viewController: UIViewController, direction: TransitionDirection = .Forward, animated: Bool = true) {
currentViewController.willMove(toParentViewController: nil)
addChildViewController(viewController)
// ... set up frames, other animation prep ...
contentContainerView.addSubview(comingView)
UIView.animate(duration: 0.5, animations: {
// do the animations
}) { (finished) in
leavingView.removeFromSuperview()
self.currentViewController.removeFromParentViewController()
viewController.didMove(toParentViewController: self)
// final clean up
}
}
How would the newer transitioning APIs improve this? From what I understand, these APIs are even more complicated to use if you are rolling your own container view controllers (see custom-container view controller transitions.
Is the value in the transitioning APIs mostly for interactive transitions?
Thanks for clarifying
UIAlertController
is not very much. – Pharmacology