代码改变世界

创建纯洁的TableViewCell

2015-10-06 09:27  Y了个J  阅读(169)  评论(0编辑  收藏  举报

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

{

    //    声明静态字符串型对象,用来标记重用单元格

    static NSString *str = @"TableSampleIdentifier";

    //    用TableSampleIdentifier表示需要重用的单元

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:str];

    //    如果如果没有多余单元,则需要创建新的单元

    if (!cell) {

        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:str];

    }

 

    //    填充行的详细内容

    cell.detailTextLabel.text = @"详细内容";

    

    //    表视图单元提供的UILabel属性,设置字体大小

    cell.textLabel.font = [UIFont boldSystemFontOfSize:40.0f];

 

    //    设置单元格UILabel属性背景颜色

    cell.textLabel.backgroundColor=[UIColor clearColor];

 

    return cell;

}