views:

129

answers:

3

I created a custom implementation of a multi-selectable table view. Multiple rows can be selected programatically. The only part I haven't been able to figure out is how to programatically set the background view of cell to the default system cell selected color/pattern.

Does anyone know how to do this?

Thanks!

A: 

Could you please post your method:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

Same code can help to understand the problem :)

Cesar
A: 

Are you asking how to programatically select rows?

If so, then use the ‘selectRowAtIndexPath:animated:scrollPosition:‘ method call, or create the cell with

cell.selected = YES;
Paul Lynch
no, i am asking how to set the background pattern of a cell so that it appears selected
Tony
Then why not do it by selecting it?
Paul Lynch
because cell.selected doesn't let you do multiple selection. you have to implement in yourself by keeping an array of selected rows and setting those selected rows' background color to the selected color
Tony
A: 

For the first cell, set it to selected as normal. For other cells, get the class of the backgroundView of the first selected cell, instantiate a new object of that class, and assign it as the background view.

otherCell.backgroundView = [[[[[firstCell backgroundView] class] alloc] init] autorelease];
drawnonward