Card Dismissal Fixes
AppStore JSON APIs
In this video, we'll go over the various tweaks we'll need to get the dismissal effect in a much better place. Involved are a bunch of math calculations and some other minor implementation details that took a lot of research to figure out. The solution present in the video is definitely harder than other bits of code I've used but it would be worthwhile to play around with it to see what's possible and what's not. Enjoy.

Comments (10)
Shahrukh Mohammad
4 years ago
Hey Brian, I know I mentioned this before on YouTube, but I have learnt so much from you about iOS development over the past year. Especially during a time when I realised that I had no interest in pursuing a career in my engineering degree. You provided hope when all hope seemed lost
Shahrukh Mohammad
4 years ago
I just have one request. You said that it will be hard to make an Uber clone app course, that you can teach in a comprehensive manner in a video. I can see your point, so I was thinking why not make a simpler course about a navigational style app that will expose us to the relevant functionality in location services framework to get us up and running so we can play around with our own ideas as you have taught us well master
Shahrukh Mohammad
4 years ago
this is also a topic most of your students haven’t learnt about in great detail and will also provide a new dimension of variety to your offered courses. Just a suggestion, what do you think? A simpler version of maps and Uber combined
Shahrukh Mohammad
4 years ago
where you could connect with your friends and see where they are or going, if they give permission for you to see that obviously . Thinking out loud here, but maybe you can put together something like that. Either way, great content. The new App Store course seems like a full cycle for me as about this time last year I finished the very first one you uploaded on YouTube. Boy, have things changed. Hope moving out went smoothly and I wish you all the best with current and future projects
Shahrukh Mohammad
4 years ago
Ignore the previous comment, I realised if you put emojis in the comment, only the text leading up to the emoji gets uploaded here. Perhaps a bug you can look into
Shahrukh Mohammad
4 years ago
Hey Brian, I know I mentioned this before on YouTube, but I have learnt so much from you about iOS development over the past year. Especially during a time when I realised that I had no interest in pursuing a career in my engineering degree. You provided hope when all hope seemed lost, starting with your let’s build YouTube tutorials. I just have one request. You said that it will be hard to make an Uber clone app course, that you can teach in a comprehensive manner in a video. I can see your point, so I was thinking why not make a simpler course about a navigational style app that will expose us to the relevant functionality in location services framework to get us up and running so we can play around with our own ideas as you have taught us well master; this is also a topic most of your students haven’t learnt about in great detail and will also provide a new dimension of variety to your offered courses. Just a suggestion, what do you think? A simpler version of maps and Uber combined, where you could connect with your friends and see where they are or going, if they give permission for you to see that obviously . Thinking out loud here, but maybe you can put together something like that. Either way, great content. The new App Store course seems like a full cycle for me as about this time last year I finished the very first one you uploaded on YouTube. Boy, have things changed. Hope moving out went smoothly and I wish you all the best for current and future projects.
johnrm9
4 years ago
Hi Brian, Here's something cute. I don't believe Swift supports static vars in functions, so since we are persisting the beginning offset (and not using it anywhere else) for dragging our card to dismiss it - why use a class property when we can localize it to the drag handler: extension TodayController: UIGestureRecognizerDelegate { @objc fileprivate func handleDrag(_ recognizer: UIPanGestureRecognizer) { struct StaticVar { static var appFullscreenBeginOffset: CGFloat = 0 } // persists the beginning offset func scaled(_ translationY: CGFloat, from beginOffset: CGFloat) -> CGFloat { // <--- inner function let trueOffset = translationY - beginOffset let scaled = 1 - trueOffset / 1000 return min(1, max(0.5, scaled)) } if recognizer.state == .began { StaticVar.appFullscreenBeginOffset = appFullscreenController.tableView.contentOffset.y } guard appFullscreenController.tableView.contentOffset.y > 0 ? false : true else { return } let translationY = recognizer.translation(in: appFullscreenController.view).y guard translationY > 0 else { return } if recognizer.state == .changed { let scale = scaled(translationY, from: StaticVar.appFullscreenBeginOffset) let transform: CGAffineTransform = .init(scaleX: scale, y: scale) self.appFullscreenController.view.transform = transform } else if recognizer.state == .ended { handleAppFullscreenDismissal() } } func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool { return true } ... Thanks
ayon
4 years ago
Really an interesting solution! Why you used an inner function?
Binh Huynh
4 years ago
Hi Brian, Very good animation. However, I have 2 improvement I want to share regarding to fullscreen dismissal 1.While in full mode and you are pulling down to scale down the appFullscreenController to the smallest, as you release, you will see the TodayController's cell (its twin brother) waiting there! It seem better we set alpha = 0 for that cell right before having fullscreen mode. We set it back to 1 in handleAppFullscreenDismissal's completion part 2. While in full mode, in case the description text is long and you have to scroll very down to bottom, as you press Close button, the view is trying to scroll up, not so fully, and disappearing before the whole view got removed, showing the TodayController's cell in the back with different view content, making the animation very funny :)) I found a solution that make this scrolling up completely and so the transition is smoothier, using self.signFullscreenVC.tableView.scrollToRow(at: IndexPath(row: 0, section: 0), at: UITableView.ScrollPosition.top, animated: true) at the beginning of handleAppFullscreenDismissal Just some opinion. Let me know what you think. Thanks and cheer ;)
romulusc
4 years ago
hi. sorry, how did you get access to that todayCell in there to set alpha = 0 for that cell right before having fullscreen mode?
ZiadHamdieh
4 years ago
I'm a little confused about calling the scrollView property within AppFullScreenController. Since this controller inherits from UITableViewController, shouldn't we be calling the tableView property instead?
Brian Voong
4 years ago
sagaya
4 years ago
Can i ask why you didn't use UIVIewPropertyAnimator for this? I have tried to use it one time and got confused does this mean it can't be used?
Brian Voong
4 years ago
malrhex
4 years ago
Issues: everything begun with the close button, UICollectionView, didn't allow me to recognize the header.closeButton on the viewForSupplementaryElementOfKind, so I was unable to click the button. Then, I tried the dismiss with gesture and it gives me a bad behaviour while scrolling up to the top, it just dismiss the controller any where below the header.. just by scrolling 1px it just dismiss... so I can go down but if I want to go up again it will dismiss and its maybe because of this error: that has not been rendered at least once requires afterScreenUpdates:YES. I have been trying to fix it, but I am unable to do so. My third ace is just to try a semi implementation of a mix of UITableView to have the dismiss button and have nice sections below the header.
Brian Voong
4 years ago
malrhex
4 years ago
haha! omg man! thanks you!!! next episode actually solve it! on that "floating" action button? ohhh meeen!!!!!! I'm way happy with that implementation! PRETTY GOOD STUFF! love you men! and love the way you teach and figures out the bugs that we run into.
malrhex
4 years ago
johnniefujita
3 years ago
Have you Brian or anyone found a proper solution for the problem with the statusBarFrame that is deprecated? Thanks!
ajeannoel
3 years ago
Hello Brian, thanks for those amazing videos which help many of us to become better iOS developers. I'm experiencing a strange behavior while slowly dragging down the appFullscreenController. You can check the footage here: https://youtu.be/R5AFzyElxeA Do you have any additional insights/fixes or am I missing something important? Thanks.
ajeannoel
3 years ago
Please disregard my message, you're already aware of the problem (16.31 of your video). Thanks a lot.
HELP & SUPPORT