mutualmobile / MMSpreadsheetView

MIT License
193 stars 34 forks source link

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

Open sidan opened 9 years ago

sidan commented 9 years ago

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

jeffla commented 9 years ago

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

sidan commented 9 years ago

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!

jeffla commented 9 years ago

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.

sidan commented 9 years ago

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

jeffla commented 9 years ago

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.

ITDebicki commented 9 years ago

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]; } }

jeffla commented 9 years ago

@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?

ITDebicki commented 9 years ago

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

sidan commented 9 years ago

@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..