I am trying to implement a custom transition between two viewControllers. ( Swift 3.0 )
Between my two view controllers there is UISeguewith type show( animated = true).
So, I set the delegate methods UIViewControllerTransitioningDelegatein the extension of my first view controller:
extension DocumentsViewController : UIViewControllerTransitioningDelegate { ... }
And I also performed the necessary methods according to the protocol:
animationController(forPresented presented: UIViewController, presenting: UIViewController, source: UIViewController) -> UIViewControllerAnimatedTransitioning? {
...
}
public func animationController(forDismissed dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? {
...
}
Now that it is done segue, in firstViewControllerI use the delegate method prepareForSegueto finally set transitioningDelegatein my `secondViewController, see below:
public override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
super.prepare(for: segue, sender: sender)
if let destination = segue.destination as? DocumentDetailViewController {
destination.transitioningDelegate = self
}
}
, firstViewController.
transitioningDelegate firstViewController , .
?
PS: segue have Animated to true, , .
.
:. MadreDeDios, Matt Tushar.
1: , viewController UINavigationControllerDelegate UIViewControllerTransitioningDelegate. (. MadreDeDios).
2: :
public func navigationController(_ navigationController: UINavigationController, animationControllerFor operation: UINavigationControllerOperation, from fromVC: UIViewController, to toVC: UIViewController) -> UIViewControllerAnimatedTransitioning? {
...
}
3: viewDidLoad() firstViewController (. ):
override public func viewDidLoad() {
super.viewDidLoad()
self.navigationController?.delegate = self
}
4: push segue secondViewController (. Tushar).
, .