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; }
  • 相关阅读:
    作业八
    作业七:用户体验设计案例分析
    作业六。合作编程
    作业五:需求分析
    作业四:结对编程2
    作业四:合作
    作业三:词频统计
    学习进度表
    java程序练习
    简单博客练习
  • 原文地址:https://www.cnblogs.com/joesen/p/4385929.html
Copyright © 2011-2022 走看看