开发者社区> 问答> 正文

关于tableviewcell 点击时改变的各种问题,求大神,要哭了

本人是刚转iOS开发的菜鸟,在做demo的过程中遇到了一点系列问题,求大神一解疑惑。

这是简单的代码:
screenshot
screenshot
screenshot

展开
收起
杨冬芳 2016-06-28 17:04:42 1833 0
1 条回答
写回答
取消 提交回答
  • IT从业

    for (UIView *view in cell.contentView.subviews) {

        [view removeFromSuperview]; 
    
    } 
    

    if(_current == indexPath.row) {

        cell.textLabel.text = @"中国国足"; 
    
        CGRect rect = cell.frame; 
    
        rect.origin.y +=20; 
    
        UILabel *label =  [[UILabel alloc]initWithFrame:rect]; 
    
        label.text=@"hello"; 
    
        [cell addSubview:label]; 
    
         cell.contentView.backgroundColor = [UIColor redColor]; 
    
    }else{ 
    
        cell.textLabel.text = @"进球了"; 
    
    } 
    
    2019-07-17 19:48:29
    赞同 展开评论 打赏
问答分类:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载