Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom cells? #4

Closed
jpaas opened this issue Oct 8, 2013 · 8 comments
Closed

Custom cells? #4

jpaas opened this issue Oct 8, 2013 · 8 comments

Comments

@jpaas
Copy link

jpaas commented Oct 8, 2013

I tried using this with a custom storyboard table prototype cell. But as I change the parent from UITableViewCell to SWTableViewCell, the cell is rendered as a blank cell.

Does it work with custom cells or only basic?

@CEWendel
Copy link
Owner

CEWendel commented Oct 8, 2013

For custom cells I recommend adding views to the cell's content view programmatically, the SWTableViewCell will still work as expected and you will have custom cell content

For example if I wanted to add a large red blob in all my cells I would add something in my - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath when I am setting up the cell

UIView *redblob = [[UIView alloc] init];
redblob.frame = CGRectMake(0, 0, 90, 90);
redblob.backgroundColor = [UIColor redColor];
[cell.contentView addSubview:redblob];

This will make my cells look like this:
screen shot 2013-10-08 at 2 46 54 pm

And the cell will still work as expected. So simply adding things programmatically to the content view will still work. This is because essentially the way SWTableViewCell works is it takes all the subviews in the content view and adds them to the UIScrollView that lives at the top of the subview stack for the UITableViewCell

Now that I think about it I should probably add this to the README...

@CEWendel CEWendel closed this as completed Oct 8, 2013
@supwy
Copy link

supwy commented Oct 12, 2013

but adding subviews programmatically is not convenient, and adding auto layout constraints programmatically without help of IB is hard.

@amitsaxena688
Copy link

i am adding view programatically but it got crashed when i am having more than 20 rows.
I agree to @supwy this does not look convenient.

@napolux
Copy link

napolux commented Feb 2, 2014

This is happening also to me.

@amitsaxena688
Copy link

@napolux can i check your code
copy paste your code and also error what does it say?

@tyegah
Copy link

tyegah commented Feb 25, 2014

This also gives me a blank cell when adding the view with IB. I was wondering if I did something wrong, but now it seems like it's not supported yet for this library?

@dropofffood
Copy link

Anybody find a solution im having the same problem

@RollingGoron
Copy link

I'm also having a problem with this as well. I keep returning a black cell. If I use the default cell textlabels eg. textLabel and detailTextLabel I can get information to pup up, but that kind of defeats the purpose of the custom cell.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants