Weird uitableview behaviour in iOS11. Cells scroll up with navigation push animation
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.
In the iOS 11 update, developers encountered an unusual behavior in `UITableView` where cells seem to scroll up when performing a navigation push animation. This issue has puzzled many and requires a deeper dive into the changes introduced with iOS 11.
Overview of the Behavior
When performing navigation from one view controller to another, developers noticed that during the push animation, the cells in the originating `UITableView` appear to scroll upward. This unexpected behavior is visually jarring and can give the appearance of a malfunction in the app's interface.
Technical Explanation
This behavior is primarily due to changes in the way iOS 11 handles the layout and animations of `UITableView`. Here are the key factors contributing to this issue:
- Changes in Auto Layout: iOS 11 introduced some modifications in the Auto Layout engine that affect how views are presented and animated. The new engine aims for more efficient and smoother animations, but it sometimes results in unexpected behavior when combined with certain view hierarchies or settings.
- Automatic Content Insets Adjustments: iOS 11 introduced automatic adjustments of scroll view insets co-operating better with large titles and translucent navigation bars. However, this feature can interfere with custom configurations, causing unexpected layout shifts during animations.
- Pre-layout and Post-layout Animations: The `UITableView` now tries to maintain post-layout consistency by aligning its pre-layout frame to what it expects during animations, sometimes resulting in pre-emptive content movement before the navigation push begins.
Reproducing the Issue
To see this behavior in action, consider the following example:
- Impact on UI Testing: Automated UI tests might fail if they rely on strict checks for content positions. Consider modifying tests to account for this behavior.
- Accessibility Considerations: Ensure that any manual handling of animations or layouts does not inadvertently impact voiceover or other accessibility features.
- Performance: Introducing custom animations or disabling system behaviors might affect the app’s performance; hence, it's crucial to test for any lag or stutter.
Related reading
- What APIs are used to draw over other apps like Facebook's Chat Heads?
- What are .dex files in Android?
- What are File Owner and First Responder in iOS - Xcode?
- What are 'get' and 'set' in Swift?
- What are my options for storing data when using React Native? iOS and Android
- What are my options for storing data when using React Native? iOS and Android
- What are the Android SDK build-tools, platform-tools and tools? And which version should be used?
- What are the differences between a UIView and a CALayer?
.png&w=3840&q=75)
Tackling System Design Interview Problems
A short course that equips you with the skills to approach system design interviews methodically.
Start the free courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.