Keyboard avoiding in SwiftUI
summary
Compares several open source approaches, finds their animations out of sync with the keyboard and extra gestures cause bugs, then builds a custom keyboard avoiding solution that combines a UIKit controller wrapper around SwiftUI views with keyboard notifications taken from userInfo so animation duration and curve match exactly. It detects the first responder, finds the enclosing scroll view, scrolls the active field into view and respects a bottom content padding. Result synchronizes animations with the keyboard and fixes many edge cases while keeping scroll interaction intact.
AI-written summary · about
chapters (40)
- 0:00Welcome
- 1:05Speaker intro
- 2:07Keyboard problem in SwiftUI
- 3:09Third-party libraries overview
- 4:59KeyboardObserving testing
- 6:02Animation bugs
- 7:10First library findings
- 7:53KeyboardToolbar overview
- 8:54Library code analysis
- 10:17Performance issues
- 11:00KeyboardToolbar testing
- 12:48Second library findings
- 13:54Keyboard problem pre-SwiftUI
- 14:18Apple’s iOS 14 solution
- 15:25ScrollView and TextField issues
- 16:33Keyboard animation setup
- 17:36Standard solution limits
- 18:20Library and animation issues
- 19:43Custom solution plan
- 20:04Disabling standard input
- 20:27KeyboardController usage
- 21:54Padding approach
- 23:01Why KeyboardController
- 24:07Modal window issues
- 25:31Content padding setup
- 26:34Main algorithm
- 27:17Solution test results
- 28:22ScrollView part two
- 29:08ScrollView animation issues
- 30:35Finding first responder
- 31:42Finding ScrollView in hierarchy
- 32:44Nested ScrollView issues
- 33:27Keyboard distance setup
- 34:54UIKit TextField issues
- 35:17ScrollView findings
- 36:02KeyboardScrollAdvocator bonus
- 37:10Ending text editing
- 38:40SiteReporter bonus
- 39:45Conclusion and experiments
- 40:07Q&A
related talks
34mFull Keyboard Control in UIKit Apps
30mEvolving Existing Projects With SwiftUI
35mSwiftUI Performance for Demanding Apps
38mEverything about iOS keyboards and text input
39mBuilding REUSABLE SwiftUI components
20mDeep Dive into Storyboard
33mCombining SwiftUI and UIKit, AppClips and Widgets
31mThe Swift Behind SwiftUI
