zoukankan      html  css  js  c++  java
  • xib和Storyboard 创建Cell的方式

    xib 方式
    1.在Cell.h文件中加一个宏
    #define cellIdentifier @"customCell"
    
    2. ViewController中:
    - (void)viewDidLoad {
        [super viewDidLoad];
    
        [_tableView registerNib:[UINib     nibWithNibName:cellIdentifierbundle:nil] forCellReuseIdentifier:cellIdentifier];
    }
     
    
    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
        CustomCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
    
        return:cell
    }    
    
    StoryBoard方式
    1.在Cell.h文件中加一个宏
    #define cellIdentifier @"customCell"
    备注:IB中Identifier 也要填 customCell
    
    2.ViewController
    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
        
       CustomCell *cell = [self.tableView dequeueReusableCellWithIdentifier:CustomCellIdentifier forIndexPath:indexPath];
    return cell; }
  • 相关阅读:
    SDOI2008 Sandy的卡片
    BZOJ2555 Substring
    CTSC2012 熟悉的文章
    递增
    丢失的牛
    【模板】点分治
    陌上花开(三维偏序)
    Holes(河鼠入洞)
    弹飞河鼠
    树状数组1
  • 原文地址:https://www.cnblogs.com/joesen/p/4385929.html
Copyright © 2011-2022 走看看