Weird uitableview behaviour in iOS11. Cells scroll up with navigation push animation
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
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.

