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.
@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.
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.
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: