# iOS Animation Tutorial: Custom View Controller Presentation Transitions | raywenderlich.com

**URL:** <https://forums.kodeco.com/t/ios-animation-tutorial-custom-view-controller-presentation-transitions-raywenderlich-com/72810>\
**Category:** 🎓 Courses & Articles\
**Created:** [June 3, 2019, 1:38pm UTC](https://forums.kodeco.com/t/ios-animation-tutorial-custom-view-controller-presentation-transitions-raywenderlich-com/72810 "2019-06-03T13:38:30Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![icanzilb](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/icanzilb/32/109333_2.png) [@icanzilb](https://forums.kodeco.com/u/icanzilb)\
**Post date:** [June 3, 2019, 1:38pm UTC](https://forums.kodeco.com/t/ios-animation-tutorial-custom-view-controller-presentation-transitions-raywenderlich-com/72810/1 "2019-06-03T13:38:30Z")

</div>

Learn how to create custom view controller presentation transitions and spice up the navigation of your iOS apps!

* * *
This is a companion discussion topic for the original entry at [https://www.raywenderlich.com/2925473-ios-animation-tutorial-custom-view-controller-presentation-transitions](https://www.raywenderlich.com/2925473-ios-animation-tutorial-custom-view-controller-presentation-transitions)

---

<div class="post-metadata">

**Author:** ![awaisfayyazbp](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/awaisfayyazbp/32/108688_2.png) [@awaisfayyazbp](https://forums.kodeco.com/u/awaisfayyazbp)\
**Post date:** [June 20, 2019, 10:22am UTC](https://forums.kodeco.com/t/ios-animation-tutorial-custom-view-controller-presentation-transitions-raywenderlich-com/72810/2 "2019-06-20T10:22:14Z")

</div>

hi there,  
Great tutorial.  
One small issue is this. sometimes the animation takes time(2 - 4 seconds). Sometimes, the animation does not go into full screen. I have to tap again. Can you tell me what can be the cause?  
i tested on iphone x simulator and iphone 6 device.

Thanks for the article.

---

<div class="post-metadata">

**Author:** ![hafizu](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/hafizu/32/81494_2.png) [@hafizu](https://forums.kodeco.com/u/hafizu)\
**Post date:** [June 24, 2019, 6:24am UTC](https://forums.kodeco.com/t/ios-animation-tutorial-custom-view-controller-presentation-transitions-raywenderlich-com/72810/3 "2019-06-24T06:24:55Z")

</div>

This is due to tableView didSelectRowAt:

Adding following there would solve this problem  
tableView.deselectRow(at: indexPath, animated: **false** )

But you’ve to manually maintain indexPathForSelectedRow

---

<div class="post-metadata">

**Author:** ![emirb](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/emirb/32/81494_2.png) [@emirb](https://forums.kodeco.com/u/emirb)\
**Post date:** [July 12, 2019, 2:10pm UTC](https://forums.kodeco.com/t/ios-animation-tutorial-custom-view-controller-presentation-transitions-raywenderlich-com/72810/4 "2019-07-12T14:10:02Z")

</div>

hello, thanks for tutorial.  
i want to use self.present, i don’t like segue.  
how can i do make this ?

---

<div class="post-metadata">

**Author:** ![shogunkaramazov](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/shogunkaramazov/32/108826_2.png) [@shogunkaramazov](https://forums.kodeco.com/u/shogunkaramazov)\
**Post date:** [August 22, 2019, 2:10am UTC](https://forums.kodeco.com/t/ios-animation-tutorial-custom-view-controller-presentation-transitions-raywenderlich-com/72810/5 "2019-08-22T02:10:10Z")

</div>

@fbrancati Can you please help with this when you get a chance? Thank you - much appreciated! :]

---

<div class="post-metadata">

**Author:** ![fbrancati](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/fbrancati/32/109968_2.png) [@fbrancati](https://forums.kodeco.com/u/fbrancati)\
**Post date:** [August 27, 2019, 9:33pm UTC](https://forums.kodeco.com/t/ios-animation-tutorial-custom-view-controller-presentation-transitions-raywenderlich-com/72810/6 "2019-08-27T21:33:16Z")

</div>

@emirb Storyboards are just another way of doing UI. You can avoid the performSegue call and create the UIViewController directly and using the “present” API instead. You can do that by using XIBs or by code. Anyway, I suggest you use Storyboards and segues, you can achieve the same things just easier.

---

<div class="post-metadata">

**Author:** ![aclynes99](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/aclynes99/32/81494_2.png) [@aclynes99](https://forums.kodeco.com/u/aclynes99)\
**Post date:** [September 29, 2019, 6:57am UTC](https://forums.kodeco.com/t/ios-animation-tutorial-custom-view-controller-presentation-transitions-raywenderlich-com/72810/7 "2019-09-29T06:57:44Z")

</div>

Great article, but I get a crash on the line:  
transitionContext.view(forKey…  
Fatal error: Unexpectedly found nil while unwrapping an Optional value  
I’m running XCode 11 with an IOS 13 simulator.

---

<div class="post-metadata">

**Author:** ![valera](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/valera/32/81494_2.png) [@valera](https://forums.kodeco.com/u/valera)\
**Post date:** [October 2, 2019, 8:27am UTC](https://forums.kodeco.com/t/ios-animation-tutorial-custom-view-controller-presentation-transitions-raywenderlich-com/72810/8 "2019-10-02T08:27:15Z")

</div>

Yes you’re right, the animator crashes because it tried to unwrap a view which is not available anymore.

The property `toView` which you used during the presentation actually becomes a `fromView` during dismissal.

It was used earlier in the tutorial but is actually not needed at the end because we’re using `recipeView` instead.

To fix it you can simply remove the property `toView` and incorporate it into `recipeView` like so:

```
let containerView = transitionContext.containerView

let recipeView = presenting ? transitionContext.view(forKey: .to)! : transitionContext.view(forKey: .from)!

```

Note how the faulty line has been removed in the middle an added in `recipeView`

Doing this will trigger another error a bit further in the method as it’s trying to add `toView` as subview, which is not possible because we juste removed it. Lucky for us we incorporated it in `recipeView` so you can add that one instead:

```
containerView.addSubview(recipeView)
containerView.bringSubviewToFront(recipeView)

```

Tadaa, the whole shebang should work again!

Enjoy your new animation!

---

<div class="post-metadata">

**Author:** ![shogunkaramazov](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/shogunkaramazov/32/108826_2.png) [@shogunkaramazov](https://forums.kodeco.com/u/shogunkaramazov)\
**Post date:** [November 14, 2019, 8:35am UTC](https://forums.kodeco.com/t/ios-animation-tutorial-custom-view-controller-presentation-transitions-raywenderlich-com/72810/9 "2019-11-14T08:35:49Z")

</div>

@valera Thank you for sharing your solution - much appreciated! :]

---

<div class="post-metadata">

**Author:** ![shogunkaramazov](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/shogunkaramazov/32/108826_2.png) [@shogunkaramazov](https://forums.kodeco.com/u/shogunkaramazov)\
**Post date:** [January 14, 2020, 11:19pm UTC](https://forums.kodeco.com/t/ios-animation-tutorial-custom-view-controller-presentation-transitions-raywenderlich-com/72810/10 "2020-01-14T23:19:26Z")

</div>

This tutorial is more than six months old so questions are no longer supported at the moment for it. Thank you!

---

<div class="post-metadata">

**Author:** ![shogunkaramazov](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/shogunkaramazov/32/108826_2.png) [@shogunkaramazov](https://forums.kodeco.com/u/shogunkaramazov)\
**Post date:** [January 14, 2020, 11:19pm UTC](https://forums.kodeco.com/t/ios-animation-tutorial-custom-view-controller-presentation-transitions-raywenderlich-com/72810/11 "2020-01-14T23:19:30Z")

</div>

Closed on January 14, 2020, 11:19pm UTC


