ios-表视图-问题

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString * cellIdentifier=@"cell";//标示符,每个表格的cell都不一样,我们可以将一定相同的cell用一个表示符指定以下。这个是在预编译的时候就放到内存了的
    UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:cellIdentifier];//根据标示符在池子里面取cell
    if (cell==nil) {
        cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];//取不到就创建
    }
    cell.backgroundColor=nil;
    NSString *fontname=_fontarray[indexPath.section][indexPath.row];
    cell.textLabel.text=fontname;
    cell.textLabel.font=[UIFont fontWithName:fontname size:14];

cell.selectionStyle=UITableViewCellSelectionStyleDefault;//设置选中状态,默认选中状态背景是蓝色的
    //设置背景视图
    UIImageView *cellbackgroundview=[[UIImageView alloc]initWithFrame:CGRectZero];
    cellbackgroundview.backgroundColor=[UIColor brownColor];
    cell.backgroundView=cellbackgroundview;
    
    //设置选中背景
    UIImageView* selectcellbackgroundview=[[UIImageView alloc]initWithFrame:CGRectZero];
    selectcellbackgroundview.backgroundColor=[UIColor purpleColor];
    cell.selectedBackgroundView=selectcellbackgroundview;

 

return cell;
}

 

posted @ 2014-04-09 22:48  离子  阅读(118)  评论(0编辑  收藏  举报