I have a static UITableView and everything is laid out on the Storyboard. In cellForRowAtIndexPath i simply use
return [super tableView:tableView cellForRowAtIndexPath:indexPath];
and the tableview works great. However I want to set the cells backgrounds to [UIColor clearColor] How can I do this? The table has 30 cells, each one different.
Thanks
I'm not entirely sure if this will work, because I've never tried using super
to manage the cells. If your code works with super
, then you should be able to get away with doing this to set the background color:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = [super tableView:tableView cellForRowAtIndexPath:indexPath]; cell.backgroundColor = [UIColor clearColor]; return cell; }
Either way, this seems to me like a strange way of doing things. Normally the cells are created and reused in the method itself, as per the default UITableView
boiletplate code, without calling super
.
Try this delegate method:
- (void) tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath { cell.backgroundColor = [UIColor clearColor]; }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With