开发者

How can set the background view of a UITableViewCell to the selected background when it is not selected?

开发者 https://www.devze.com 2022-12-27 17:01 出处:网络
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 back

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!


Could you please post your method:

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

Same code can help to understand the problem :)


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;


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];
0

精彩评论

暂无评论...
验证码 换一张
取 消