UIImageview animation and UILabel inside UICollectionview disappearing - ios

I'm having problems with an animation inside the UICollectionview cell. When I touch my animation, it disappear. I have a refresh time of 8 seconds and when this time is reached, the animation back to normal. My labels inside the cells are having the same issue. It's weird this behavior because when I use static images, they don't disappear.

Arrived while looking for the answer to this. Faced similar issue. Image animation would stop when clicked on the collectionViewCell.
Not sure what the bug is, but one solution that worked for me, was to disable selection on the CollectionView.
In case, you do not need selection on the collection view, just set allowsSelection to NO for the collection view and the bug will go away.

Related

UITableView do not respond some touches while scrolling

When tableView is scrolling with high speed, and user tries to stop it by touch, tableView keeps scrolling. And user can stop scrolling tableView only after two or three touches. If speed of tableView scrolling is low, tableView respond touches well.
The tableView displays cells with a lot of subviews, and I localized problem on one view.
If I set problemView.userInteractionEnabled = NO, scrolling works well. To set userInteractionEnabled = NO for all subviews of problemView but not for problemView, do not help.
Here image of diplaying cell, the problemView is view with red frame.
Could somebody to give an advice, how to solve the problem?
There are several possibilities:
Your custom view, or one of its superviews, has userInteractionEnabled set to NO.
There is another view on top of your custom view, or on top of the table view within the custom view.
The custom view that the table view is inside is smaller than the table view (with clipsToBounds=NO, a subview that extends beyond the bounds of its parent can be seen but not normally interacted with). Or the same for another view in the stack.
The custom view (or one of its superviews) overrides pointInside:withEvent: or hitTest:withEvent: incorrectly.
It might be that it thinks you are editing it in some way. Try allowsSelectionDuringEditing = YES. Here is more information with using the UITableView.
If you are using NSTimer inside the UITableViewCell then I have experienced anomalous actions as you have discussed. In such case you need to replace implicitly scheduled timer with explicitly scheduled timer.
For me the problem was that having userInteractionEnabled = true with a click handler on subviews in the cell broke the scrolling. Not sure why this is the case though. I solved this in my case by using didSelectRowAt on the tableview instead of having custom click handlers on the subviews. Then both the scrolling and the click handling worked as I wanted to.

Why UICollectionView offset changes when keyboard appears

I'm developing an iPad app, that has a horizontal UICollectionView. Each of the cells has a UITextField. When the UITextField becomes first responder, the keyboard automatically comes up, and surprisingly all the cells move upwards.
I haven't implemented any logic for the cells to move upwards. Do you know why?
I haven't found any documentation regarding this, and I'm unable to fix this.
This behaviour is implemented by Apple. The standard UICollectionView takes care for you to scroll to the correct position if a keyboard appears. Why would you want to fix this?

Strange behaviour when scrolling just one time UITableView. Can't scroll anymore

So, I've got an UITableView with a Custom Cell
and this is my View Hierarchy:
So, the last view on the top is part of the Custom Cell.
Now I scroll (just touch up, or scroll a little bit), and I get this new View Hierarchy:
I'm getting a last UIView which is not letting me scroll anymore.
Any clue of what is it?
Thank you very much.
Ok, solved.
It was because of it was an instance of MMDrawerController.

UITableViewController scrollViewDidScroll: not called during cell removal

I have a tableView whose content is smaller than the screen, so its not scrolling.
I'm reloading one of the sections when changing to editing mode, which causes the tableView to add rows.
When I now scroll down and then deactivate the editing mode, the tableView removes the redundant cells again and scrolls to top.
During this scroll operation I'm not getting any scrollView delegate calls.
For details, please check my implementation: GISTViewController.m
Well, after reading your question a few times, it looks like our issues aren't the same.
I believe your issue is because scrollViewDidScroll: is not called during some animations. You should see this answer here, though unaccepted (maybe because they imply user interaction is the only way to trigger it), it also contains a path to this answer about getting scrolling events during automated animations which may be of help.

UITableViewController weird behavior after popping a view controller

My UITableView has a bunch of reusable cells, and when I tap on one of them, it takes me to another view controller (via push segue) showing the details of that cell (let's say it's an item, so it would show details about an item - name, price, image, etc...). When I pop that view controller (by tapping on the back button), the UITableView has a strange behavior:
a) if it's scrolled all the way to the bottom, it will scroll automatically tad up (around 50 points), leaving the last cell barely visible, so I have to scroll back down again. My cell all have 60 points for height.
b) the scrollbar always shows and then disappears, indicating that something is moving that UITableView (although if not scrolled to the bottom, the content will not move automatically).
This happens in multiple UITableView's I have in my app. I am not forcing a reload of the table view in viewWillAppear, so I don't understand what is happening. My content is static after loading from the server (unless the user changes it, and then the reload is executed). But simply showing details of an item and popping that VC doesn't change anything in the table view.
Edit: Okay, I've figured what the problem is: I'm hiding a UIToolbar when pushing that segue. If I keep it always visible (which I don't want), it still shows the scrollbars animating when popping in my table view but doesn't scroll the table view if on the last few rows.
Add the following to viewDidLoad.
self.automaticallyAdjustsScrollViewInsets = NO;
This solved my problem of table view moving down after navigating back to view controller.
I managed to fix the first issue. It seems like the tableview is not taking into account the 44 points of the UIToolbar.
Save the tableview offset in prepareForSegue: (save it in a CGPoint property)
self.tableViewScrollOffset = self.tableView.contentOffset;
Then, in viewWillAppear:, check if it has been modified. If so, restore it.
if(self.tableView.contentOffset.y != self.tableViewScrollOffset.y) {
[self.tableView setContentOffset:self.tableViewScrollOffset];
self.tableViewScrollOffset = CGPointZero;
}
This behavior is indeed a bug in iOS 8.x.
All answers given so far can not really solve the issue. The issue is, that iOS forgets (or doesn't) consider the previously calculated cell sizes, when a table is being redrawn for instance when the view is being pushed.
One approach to solve this can be found here: UITableView layout messing up on push segue and return. (iOS 8, Xcode beta 5, Swift) (so this question is even a duplicate to this one).
However, the solution provided there is overkill and there are certain situations why this caching will fail (for instance a UIContentSizeCategoryDidChangeNotification is not regarded)
But there is a quite simpler solution even though it is odd:
If you are using a manual performSequeWithIdentifier in didSelectRowAtIndexPath, just add a [self.tableView reloadData] just before.
If you are using a IB seque from the cell, just add [self.tableView reloadData] in your prepareForSeque code.
The reason, why this solves the issue is, that this will force iOS to re-estimate the visible cells and so it no longer scrolls the content to another location. Fortunately, tableView reloadData doesn't cost too much overhead here as only the visible cells will be re-estimated.
Just a hunch, have you got a rogue scrollToRowAtIndexPath:atScrollPosition:animated hanging around?
I was also facing this issue. I managed to find it out. The reason in my case is tableview header height was calculating based text and text height was negative due to which tableview was shifting down even though the contentinset and scrollinset are zero.
This was only occurring for first time. Next time it is calculating correct. One weired thing i found is that when Class A (having tableview) have pushed another Class B from init. When keyboard from Class B is opened viewDidLoad of Class A is called. and before Class B is unloaded from navigation controller. Tableview is reloaded for Class A.
Setting the automaticallyAdjustsScrollViewInsets as suggested above did not work neither did caching and setting the tableViewScrollOffset work.
Hence came up with an workaround which worked like a charm for me.
The workaround was to add an Dummy UIView which has height of 1px and width of 320px and place it between the "Top Layout Guide" and the UITableView. This view's background could be set to clear so that it is invisible.
Now using Autolayouts, fix the Dummy View's top to the Top. Now set the tableview's top constraint with respect to Dummy View. Found that this resolved the issue of the tableview's misplacement.
Screenshot of the Dummy View along with the autolayout constraints have been provided for easy reference. The Dummy View has been set to a larger height and red background colour for illustration purpose only.

Resources