zoukankan      html  css  js  c++  java
  • Swift自定义TableVIewCell 和OC 自定义TableVIewCell 的区别

    oc 

    cell里
    -(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{ if (self=[super initWithStyle:style reuseIdentifier:reuseIdentifier]) { [self addSubview];//添加控件 } return self; } 调用 static NSString *talkID=@"talkID"; CSDA_LZSearchTalkTVCell *cell=[tableView dequeueReusableCellWithIdentifier:talkID]; if (cell==nil) { cell=[[CSDA_LZSearchTalkTVCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:talkID]; } cell.selectionStyle=UITableViewCellSelectionStyleNone; return cell;

    Swift 

    cell 里
    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
            super.init(style: style, reuseIdentifier: reuseIdentifier)
           
            self.setUI()//添加控件
            
        }
    调用
     func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
            
            let reuSre = "cell"
            let cell = MasonryTableViewCell(style:UITableViewCellStyle.default,reuseIdentifier:reuSre)
            cell.selectionStyle=UITableViewCellSelectionStyle.none
            cell.titeLB.text = array[indexPath.row] as? String
            let imageName = String (indexPath.row)
            cell.imageVI.image = UIImage(named:imageName)
            return cell
        }
  • 相关阅读:
    xrange和range区别
    bool([x]) 将x转换为Boolean类型
    bin(x) 将整数x转换为二进制字符串
    chr(i) 返回整数i对应的ASCII字符
    音乐欣赏
    迅雷下载百度云引发的“事故”
    swift获取图片路径出错
    记号笔写在白板上引起的尴尬而又无奈的事件
    swift 3新特性总结
    watch
  • 原文地址:https://www.cnblogs.com/Lrx-lizi/p/7268778.html
Copyright © 2011-2022 走看看