码迷,mamicode.com
首页 > 其他好文 > 详细

设置cell选中颜色以及表格默认选中某行

时间:2014-11-21 10:41:57      阅读:220      评论:0      收藏:0      [点我收藏+]

标签:ios   uitableviewcell   

1.在加载cell的地方(即 (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath里面)加上下面几句代码

        [cell setBackgroundColor:CLEARCOLOR];

        cell.selectedBackgroundView = [[UIView alloc] initWithFrame:cell.frame];

        cell.selectedBackgroundView.backgroundColor = COLOR(255, 255, 255, 1.0);


2.制定表格默认选中某一行

//设置选中第一行  

            [self.tableView selectRowAtIndexPath:[NSIndexPath indexPathForItem:0 inSection:0] animated:YES scrollPosition:UITableViewScrollPositionTop];

            if ([self.tableView.delegate respondsToSelector:@selector(tableView:didSelectRowAtIndexPath:)])

            {

                [self.tableView.delegate tableView:self.tableView didSelectRowAtIndexPath:[NSIndexPath indexPathForItem:0 inSection:0]];

            }



设置cell选中颜色以及表格默认选中某行

标签:ios   uitableviewcell   

原文地址:http://blog.csdn.net/gorgeous_xie/article/details/41344641

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!