how can I fix the animation glitch when the keyboard is dismissed over a swiftui list with a safe content inset?
Asked on 07/31/2024
1 search
To fix the animation glitch when the keyboard is dismissed over a SwiftUI list with a safe content inset, you can leverage the new scrolling enhancements and improved interoperability between SwiftUI and UIKit introduced in WWDC 2024.
Relevant Sessions:
- What’s new in SwiftUI - This session discusses the new scrolling enhancements in SwiftUI, which provide more programmatic control over scroll views and additional scroll positions.
- Enhance your UI animations and transitions - This session covers how to handle state during transitions and how to incorporate SwiftUI into your app for better handling of continuously changing states.
- What’s new in UIKit - This session highlights the improved interoperability between SwiftUI and UIKit, allowing you to use SwiftUI animations to animate UIKit views.
Steps to Fix the Animation Glitch:
-
Use New Scrolling Enhancements:
- SwiftUI now offers more programmatic control over scroll views, including the ability to programmatically scroll to specific positions like the top edge. This can help ensure that your list scrolls smoothly when the keyboard is dismissed.
- Refer to the What’s new in SwiftUI session for more details on these enhancements.
-
Handle State During Transitions:
- Ensure that you reset any state changes by using
viewDidAppear
orviewDidDisappear
methods. This can help in cleaning up any transition states that might be causing the glitch. - Check out the Enhance your UI animations and transitions session for tips on managing state during transitions.
- Ensure that you reset any state changes by using
-
Leverage SwiftUI and UIKit Interoperability:
- Utilize the new APIs that allow SwiftUI animations to animate UIKit views. This can help in creating a seamless animation experience across both frameworks.
- For more information, see the What’s new in UIKit session.
By following these steps and utilizing the new features and improvements discussed in these sessions, you should be able to fix the animation glitch when the keyboard is dismissed over a SwiftUI list with a safe content inset.

What’s new in UIKit
Explore everything new in UIKit, including tab and document launch experiences, transitions, and text and input changes. We’ll also discuss better-than-ever interoperability between UIKit and SwiftUI animations and gestures, as well as general improvements throughout UIKit.

What’s new in SwiftUI
Learn how you can use SwiftUI to build great apps for any Apple platform. Explore a fresh new look and feel for tabs and documents on iPadOS. Improve your window management with new windowing APIs, and gain more control over immersive spaces and volumes in your visionOS apps. We’ll also take you through other exciting refinements that help you make expressive charts, customize and layout text, and so much more.

What’s new in AppKit
Discover the latest advances in Mac app development. Get an overview of the new features in macOS Sequoia, and how to adopt them in your app. Explore new ways to integrate your existing code with SwiftUI. Learn about the improvements made to numerous AppKit controls, like toolbars, menus, text input, and more.