开发者

Question about a selected style of UITableView

I set the Property of UITableview - "Show Selection On Touch" to YES in Interface Builder. But when I selected a row, the cell's style just changed its color to blue.

In some app which contains UITableview, when user selected a row,it will appear a '√' to represent that this row is selected开发者_StackOverflow.

I want to know how can I get this effect.

Thanks!


You can use the accessoryType property to toggle between UITableViewCellAccessoryCheckmark and UITableViewCellAccessoryNone together with -didSelectRowAtIndexPath: method to do the toggling.

For details and examples, please see this post: UITableView, having problems changing accessory when selected


In

- (void)tableView:(UITableView *)tV didSelectRowAtIndexPath:(NSIndexPath *)indexPath

do:

UITableViewCell *cell = [tV cellForRowAtIndexPath:indexPath]; 

cell.accessoryType = UITableViewCellAccessoryCheckmark;
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜