首页 > 其他 > 详细

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

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

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选中颜色以及表格默认选中某行

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!