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;
}
1.这里只记录一些学习笔记 2.这里只记录一些学习心得,如果心得方向有错,请留言 2.这里只记录一些日记(只为提升英语,暂时有点忙,等转行了开始写)
原文地址:https://www.cnblogs.com/liyang31tg/p/3655384.html