Weird issues when reloading data (iOS) - ios

I have a collectionView, called parentCollectionView, which scrolls horizontally. Inside each reusable cell is a collectionView, called childCollectionView which scrolls vertical.
I am having a strange issue. When I reloadData() on the parentCollectionView, the cell will glitch/flicker for a fraction of a second, and if you are scrolled down, it will load the childCollectionView from the top. The weirdest thing, is that it only happens the first time you call reloadData() on the parentCollectionView. Everytime after that, there is no flickering, and doesnt force you to the top. And when I ditch the reloadData() method and use reloadSections/IndexPaths it will for load from the top everytime.
What the heck is going on?

I didn't call reloadData on the parentCollectionView. Instead, I called reloadData on the childCollectionViews that are visible and set the delegate/datasource to nil, to cells that have been deallocated (in prepareForReuse).
It seems as reloading the parentCollectionView via reloadData() is redrawing everything.

Related

UITableView beginUpdate and endUpdate on last cell reloads tableview

I have a tableview with expand-collapse cells. Whenever a cell is selected, I simply call :
tableView.beginUpdate()
tableView.endUpdate()
This in turns recalls the heightForRowAtIndex method, where I set the new height and this seems to show expand-collapse behavior.(without reloading the cell).
ISSUE: When I tap on last cell(or last 2-3 cells), after tableView.beginUpdate()
tableView.endUpdate(), the table reloads itself. I have no clue why it is behaving like this.
It seams like since there is no space at the table's bottom to expand a cell, it's reloading itself.
Can someone throw light on this?
estimatedHeightForRowAt works always.

ScrollViewDidEndDecelerating gets called every time when I select cell

I know that it would be repeated question but I really stuck on it. My first CollectionView’s each cell has another collectionView as a subview. My first CollectionView has three cells with same width and height and my Second collectionView has 27 cells. I want to show edge of next and previous cells at second cells of the first collection view and got it using the ScrollViewDidEndDecelerating delegate method of the uiscrollview but the problem is the he gets called even simple touch on any collectionview item. Please help me, how do I get rid of this shit?
If anyone wouldn’t get my point I can share code as well.

why tableview cells are starts flickering when they are going to be reused?

I'm building a chat interface. I'm using multiple types of tableView cells in UITableView. Table view cells are start flickering when new cell is added into tableView from reusablecell. I'm dequeuing tableview cells with following piece of code. How get scrolling smooth with out any flickering.
tableView.dequeueReusableCellWithIdentifier("MessageLessonTableViewCell") as! MessageLessonTableViewCell
The main reason for flickering is that, tableView is getting data to be attached late in time. So when you scroll, it takes time to switch from one type of tableViewCell to another. Plus you might be doing DB operations in cellForRowAtIndexPath which delays in returning tbaleViewCell. For implementing Smooth scrolling refer this

Monotouch: Force UITableView to recalculate height of each cell without reloading data

I have a custom cell created using OwnerDrawnElement with autoresizeable UITextView in it.
When text changed there should be appropriate layout redraw and cell height recalculation.
The problem is how to preserve keyboard opened.
There is a method inside UITableView - ReloadRows which actually helped me in some fashion.
I can't call it for my cell because it is the first responder and can't I cant resign it.
But when I call it for another cell my cell is getting resized as I wanted but I have unnecessary another cell redraw.
So I wonder what method is called to relayout UITableView NOT reload data?!
The same method is probable called when you scroll up and down, cells become visible and height is recalculated.
I've tried standard SetNeedsDisplay(), SetNeedsLayout(), ReloadInputViews(), LayoutSubviews(), but it didn't do the same. Maybe I need use them somehow differently. I've tried to call them for cell and whole tableview objects.
I've looked into ReloadRows method and found out that it calls some API stuff:
Messaging.void_objc_msgSendSuper_IntPtr_int(base.SuperHandle, UITableView.selReloadRowsAtIndexPathsWithRowAnimation_, nSArray.Handle, (int)withRowAnimation);
So it doesn't what method forces tableview to recalculate height of each cell without reloading data either.
Can you help me with that?
Try to update cells frames, then call UITableView's empty update block:
tableView.BeginUpdates();
tableView.EndUpdates();

UITableView not reloading data when not visible?

I'm puzzled with this.
I have a UIScrollView and inside I have placed 4 tableViews.
The whole thing is used to allow scrolling horizontally and switching tableViews like the Groupon app.
As soon as you start scrolling the 4th (left or right) tableView, is moved in the scrollView and a reloadData is initiated on that tableView, so it will load the data from the datasource for that category.
However, when I scroll into that tableView, it still has the data from the previous category, meaning the cell's didn't get refreshed.
Can anyone shed a light on why this is happening?
I'm guessing only that because the tableView is not in a visible frame when I call the reloadData command, actual drawing is not happening in the tableView (the datasource methods are being called normally, but no drawing is happening).
Any ideas, or tips ?

Resources