Pixate / pixate-freestyle-ios

Pixate Freestyle for iOS
Apache License 2.0
848 stars 134 forks source link

UICollectioView issue with reusable cells #88

Closed fnxpt closed 10 years ago

fnxpt commented 10 years ago

I'm trying to implement pixate on a UICollectionView with different styles, but I'm not getting the correct output. After applying the cell the cell still uses the style previously defined.

screen shot 2014-04-01 at 13 05 16

pcolton commented 10 years ago

What does your CSS look like for the 'even' and 'odd' selector?

fnxpt commented 10 years ago

.even{border: 1px solid #ff0000;} .odd{border: 1px solid #0000ff;}

pcolton commented 10 years ago

I'll investigate. BTW, have you tried using

`

yourCollectionView:nth-child(even) { ... }

yourCollectionView:nth-child(odd) { ... }

`

fnxpt commented 10 years ago

Hi again... The css that you described doesn't work.

seivan commented 10 years ago

@fnxpt Not sure about collectionViews but it does work on TableViews (using pseudo selectors that is)

Try doing

#yourCollectionViewCell:nth-child(even) { ... }
#yourCollectionViewCell:nth-child(odd) { ... }

As in put it on the cells and not the collectionView.

I just tried

.ETApplicationTableViewCell {
  &:nth-child(odd) {
      background-color: $gray-superlight;
  }
}
pcolton commented 10 years ago

We have a small collection view fix coming, I'll test to see if it resolved your issue by testing your CSS.

-Paul

On Apr 1, 2014, at 7:14 AM, fnxpt notifications@github.com wrote:

Hi again... The css that you described doesn't work.

— Reply to this email directly or view it on GitHub.

pcolton commented 10 years ago

Ok, using the latest version, I was albe to use only this code (updateStyles not needed) with your css sample:

int idx = indexPath.section + indexPath.row; [cell setStyleClass: (idx % 2 == 0) ? @"even" : @"odd"];

And got this:

screen shot 2014-04-06 at 11 51 52 am

Try this 2.1.3RC2 version (link subject to disappearing): https://www.dropbox.com/s/7bc1embtexvl2t0/PixateFreestyle.framework.zip

seivan commented 10 years ago

@pcolton When do we actually call updateStyles, as in when is it necessary?

pcolton commented 10 years ago

I'll write something up soon for when to call and when not to. For cells, no need to in that method as they are styled after that method is called. Generally, styling is done in layoutSubviews so calling updateStyles depends on when your code executes. Also, setting a id or class will cause styling.

-Paul

On Apr 6, 2014, at 12:11 PM, Seivan Heidari notifications@github.com wrote:

@pcolton When do we actually call updateStyles, as in when is it necessary?

— Reply to this email directly or view it on GitHub.

fnxpt commented 10 years ago

Still having some issues... I have a more complex collectionview that should represent my problem better... https://dl.dropboxusercontent.com/u/1846454/collectionview.mov As you can see its a collectionview with multiple sections and whenever I move to another page the cellForIndexPath is called.. February and March should have only one rounded cell

pcolton commented 10 years ago

The issue might be that for the non-circled state, you need to make sure you undo whatever stylings you've set. That is, the cells are being reused, and it looks like their stylings aren't being set back, so make sure your CSS has the inverse of whatever you turned on. If you'd like, you can send your actual CSS for those cells to support at pixate dot com and I can take a look.

fnxpt commented 10 years ago

When cellForIndexPath is called I reset the styleClass and then apply the new one.

pcolton commented 10 years ago

You still need to 'reset' values you have set, iOS has no way of resetting to default values. So anything you have set (i.e. border color) that you want turned off, you need to explicitly set in the alternate style. If you remove the style, you need to instead apply a 'resetting' style.

fnxpt commented 10 years ago

Thanks.... it worked... Not sure why I was thinking that pixate will reset them for me

pcolton commented 10 years ago

We actually looked into a way to 'reset', but there's no API for doing so. We'd have to review each iOS versions' docs and see what the default values are and explicitly set them -- you are better off with a reset css file. It would be nice to start such a file that people could use to get controls back to their default states.