TableView height change while scrolling resets contentOffset - ios

I encountered an animation flicker that occurs when dragging down a UITableView. If the height of a UITableView changes during a 'rubber banding' drag, the contentOffset gets set to the contentInset when the table height change animation completes.
Here's a project reproducing the issue, as well as a bad work around. If you drag the table down, you should see the table contents flicker back to the top momentarily.
Anyone have any ideas for a better workaround?
https://github.com/KingOfBrian/AppleBugs/blob/master/ContentOffsetBug/ContentOffsetBug/RZViewController.m

Related

Change tableview content offset for reload animation

In my application I am using a TableView behind a completely transparent navigationBar.
To achieve this I am setting the top contentInset of the Tableview to -64 for all devices except the iPhone X. For the iPhone X I am setting this value to -88.
My problem is that when I am using the tableView's pull to refresh function the refreshControl is for half shown behind the tableView because the content offset for the refreshControl to be completely shown is -64.
How can I tackle that problem? Is there a possibility to tell the tableView on which contentOffset to start the refresh animation and on which contentOffset to end?

UITableView contentOffset changes on drag

I have an UITableView and I want to hide a part of it's header (kind of pull to refresh). I did it with contentOffset and it works fine when the content is larger than the screen. It hides when needed and show when needed but when the content takes up less space than the screen, it changes the contentOffset from (0,50) to (0,25.5) every time I start to scroll. I think it i not related to my code because I commented out everything that had something to do with contentOffset except the viewWillAppear method what sets the contentOffset the first time. Any idea?
On attribute inspector, unchecked Adjust Scroll View Insets as show in image below

UITableView Not Scrolling

I have a tableview which will not budge when touched. It is very confusing to me. It is the most recently added subview (I checked - it is the last entry in my view's subviews array) and for some reason it just won't scroll up or down. If I tap multiple fingers wildly on the tableview it will one in a while highlight the cell under one of my fingers, but it will not scroll even a little. I have set the number of rows to 100 (many more than are visible on screen) and I have set the 'bounces', 'scrollEnabled', and 'userInteractionEnabled' properties to YES.
I know that I have not provided much to go on here, but if anyone could at least give some tips on how to go about debugging this I would be very grateful. Can I log from within the tableView gestureRecognizer handling method? Can I test where my touches are going?
Please help!
Thanks.
A TableView is basically a specialized ScrollView. If it's not scrolling, it seems to me it could be one of two things. Either something is on top of the TableView and is capturing the gesture events before the TableView can get them, or You have set the bounds and contentSize incorrectly. For a TableView or ScrollView, the bounds of the view should be the visible area, and the contentSize (should be handled by the TableView without you needing to do anything) is the size of all the cells in the Table.
So I would check the bounds of the table view and make sure you are setting that to the contentSize, since that would cause it nor to scroll.
Just to make sure it's on the top, try calling
[view bringSubviewToFront:tableView];
In my case tableview "User Interaction" was disabled. I just enabled it & works.
In my case, tableView "canCancelContentTouches" was not enabled. I set it to true in the storyboard.
Can you check the frame of the parent on which the tableview is added? Make sure the parent view have correct frame to include the table view. I have faced this issue sometime back my table view was not responding to touches and there was some problem with frame size. Also do check the bounds and frames of your tableview
-anoop
Please check tableview scroll is enabled.
I just hate XIB and Storyboard. After 30 mins of debugging it come to know that scroll was not enable in XIB.
Thanks
Basically, Table view is just a kind of scrollview. So in case it is not scrolling You should be sure that if the frame size of your table view is less than the contentSize of your table view. For this just log the frame and content size of tableView's scroll view. If you found that frame size is greater or equal to your content size, just correct your layout constrain of your view. And I hope it will work.

Stop `UICollectionViewCell` disappearing after `UICollectionView` bounds change

I have a UICollectionView that animates its bounds when a user lifts their finger from the screen. The collection view either grows or shrinks based on how much the user scrolled. This works great if the user lifts their finger up whilst the UICollectionView is stationary however if they flick the scroll view unexpected results happen.
As you can see the UICollectionViewCell disappears before it has a chance the naturally scroll away.
I am using AutoLayout and therefore animating the constraints of the collection view calling [self.view layoutIfNeeded]; I want to suggest that the animation is getting in the way of the scrolling judging by the way the scrollbar moves, it seems to set the UICollectionView to its projected end contentOffset then animate the slide up.
I would like to know why this effect is happening? And any tips on how to fix it!

UITableView stops scrolling enough after I add/remove a view to the superview of table view

Here is the problem that I'm facing. I have UITableView inside main view. When user taps menu button, view is added to the view hierarchy of superview, and this view covers all screen, except the menu button. That is I call
[self.view insertSubview:self._menuView belowSubview:self._menuButton]
After user clicks the menu button again I call
[self._menuView removeFromSuperview]
However, after this, the UITableView stops scrolling, actually it scrolls, but just a little, couple of pixels, and then bounces back to the location on which it was before I inserted _menuView. I've monitored the menu hierarchy after inserting and removing the _menuView, it is actually removed, and also there is no view which covers the UITableVIew, so there is no chance that some other view steals touches from UITableView. What can be the problem? Any ideas?
EDIT 1: I've noticed besides not being able to scroll, another strange thing happens. When I show menuView, the tableView is scrolled to top, without animation. (the menuView is half opaque only, so I can see the tableView underneath it)
EDIT 2: I've monitored contentSize and contentOffset of tableView before and after inserting _menuView, the reason for not being able to scroll is that somehow contentSize is being changed.
TABLE VIEW BEFORE INSERTING MENU - contentSize:{Width=320, Height=10519} contentOffset:{X=0, Y=3980}
TABLE VIEW AFTER INSERTING MENU - contentSize:{Width=320, Height=44} contentOffset:{X=0, Y=0}
As You can see, the height is changed to 44 that's why I'm not able to scroll. And Also, as I've said in EDIT 1: tableView is scrolled to top - so as you can see contentOffset is also zeroed. Any ideas why content size changes automatically?
Thanks in advance.
i think there is problem with your tableview frame. right after removing subview, try to set frame of your tableview at its original frame.may this will solve your problem
Content in the UITableView organized automaically and designed only to show cells & header/footer elements. To proper working you should wrap your table into parentView and add your menu to that parentView rather than to the UITableView. You can also try to call reloadData method on table since it can restore the content size of the view.

Resources