MMSpreadsheetView icon indicating copy to clipboard operation
MMSpreadsheetView copied to clipboard

Cells are being overwritten in the screen while scrolling V or H

Open sidan opened this issue 10 years ago • 9 comments

Alright, to start, would like to say this library is a good job and help me a lot as a solution for presenting spreadsheets. Second, would like to know how to solve this issue:

I've made some customization for populate the content within the spreadsheet. But while scrolling, the cells are being drawn above each other, out of order, producing a great mess in the screen.

It goes like this: screen shot 2015-03-04 at 5 52 56 pm

But when I scroll H or V: screen shot 2015-03-04 at 5 55 11 pm

Would like to have (please) some clarification about it.

Thanks in advance

sidan avatar Mar 04 '15 20:03 sidan

Rafael,

I haven’t seen that before. Are you sure you don’t have more than 1 spreadsheet view being added to the popup?

This is just a group of UICollectionViews so I’d check to see if something is strange in the delegate calls.

Jeff

jeffla avatar Mar 04 '15 21:03 jeffla

Well, I'm actually using just one spreadsheet inside this viewcontroller but with a slight custom implementation as attached in the code below.

Here is how I'm loading the data source: screenshot 2015-03-10 21 49 40

...Here, how I'm initializing the spreadsheet: screenshot 2015-03-10 21 53 03

In the beginning I was assigning the spreadsheet to the main view and the scroll was not working properly, because the spreadsheetview was being drawn out of bounds of main view. Then, I fix it by assigning the spreadsheetview to the child view as its content. At that point, the contents of cells started to be drawn out of order while scrolling.

Really appreciate any help on this!

sidan avatar Mar 11 '15 00:03 sidan

Is initSpreadSheetView being called more then once? Try adding NSLog(@"%s", PRETTY_FUNCTION); at the top of the function and bring it up a few times (looks like it's a view inside of a popup). That method should only fire once. If it's getting called more than once, there is the problem.

jeffla avatar Mar 11 '15 04:03 jeffla

Yes, it's being called just once from viewDidLoad and I could confirm it by logging "PRETTY_FUNCTION". What else it could be? :)

sidan avatar Mar 12 '15 17:03 sidan

Did you try open and closing self.viewProdutoEmProdutos several times so see if the initializer is getting called more than once?

From what you've shown, I don't see a problem.

You might try just using a UICollectionView in place of the spreadSheetView to see if you get the same problem.

jeffla avatar Mar 14 '15 02:03 jeffla

Hi all, I ran into the same problem when I was using it. It turns out it is a problem with the uicollection view cells not being properly reused.

What I did was every time I added a cell, I removed all its child views. That fixed it for me.

Here is the code I used: -(void)resetCell{ for (UIView *view in [self.contentView subviews]) { [view removeFromSuperview]; } }

ITDebicki avatar Apr 10 '15 18:04 ITDebicki

@ITDebicki Are you saying this is a UICollectionView issue or something in @sidan 's cell implementation? Perhaps needing to check or destroy the cell's subviews in prepareForReuse?

jeffla avatar Apr 10 '15 21:04 jeffla

I didn't investigate it fully, but I just used this method in the init method of each cell

ITDebicki avatar Apr 10 '15 21:04 ITDebicki

@ITDebicki , it seems a nice work around, which I've used so far to reload the view while using this library: https://www.cocoacontrols.com/controls/tstableview that I end up with cuz of project's deadline. Thanks for supporting..

sidan avatar Apr 10 '15 22:04 sidan