having a TTTableViewController instance, I try to set the background of the currently selected cell. I am aware of the style sheets concept in Three20, but it just offers:
- (UITableViewCellSelectionStyle)tableSelectionStyle {
return UITableViewCellSelectionStyleGray;
}
with standard options UITableViewCellSelectionStyleNone, UITableViewCellSelectionStyleBlue, UITableViewCellSelectionStyleGray.
Second, I am aware, that UITableView implementations would just take a subclassed UITableViewCell. One would set selectedBackgroundView of that cell class:
UIView *myBackView = [[UIView alloc] initWithFrame:self.frame];
myBackView.backgroundColor = [UIColor colorWithRed:1 green:1 blue:0.75 alpha:1];
self.selectedBackgroundView = myBackView;
[myBackView release];
How can I set the background color of a selected cell in a three20’s TTTableViewController instance?
I figured this out tonight. I went into three20UI.xcodeproj and had a look for where the UITableViewCell was being constructed, that is the Data Source, and then I subclassed that data source which I am using to set up my table.
For example, if you’ve table that’s using a TTSectionedDataSource, then you subclass that, let’s say we call it MySectionedDataSource, and then inside the implementation for that subclass, you’ll want to do something like this:
That should do it.
At first I tried to set the selectedBackgroundView inside of
but that doesn’t seem to work. I searched to code to find out why, i.e. if something in a controller, delegate, cell, or data source were re-setting the bg selection, but nothing there. I ended up having to search so technically I didn’t solve it by myself… 🙂
Good luck.