Handle bounds change on height change #167
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The setFrame method of AQGridView used to only call handleGridViewBoundsChanged if the bounds width actually changes. (This to prevent unnecessary work if setFrame is called again with same bounds I suppose) But there are cases when the height will change and the grid content height needs to be recalculated appropriately. This patch detects a change to height as well so that happens.
In my case a large 3x4 (portrait) and 4x3 (landscape) grid table is displayed in a view with a navigation bar. A cell is selected causing another view to be pushed on the stack. That view is rotated and we return to the grid. SetFrame is called twice, the 1st time it resets the frame height & width to the new orientation, BUT without accounting for the navigation bar. The 2nd time it resets the frame to account for the bar, but the width is the same. The old logic bypassed the logic I added to the parent branch that recalculates the current content offset proportionally to the height so the content stays in view. So the 1st time setFrame is called the cells are all calculated to be a little taller (to fit) and depending on the size of the table and how far down you scrolled results in the view showing cells that are a number of rows away from those shown before the rotation.