• 爱情文章
  • 亲情文章
  • 友情文章
  • 生活随笔
  • 校园文章
  • 经典文章
  • 人生哲理
  • 励志文章
  • 搞笑文章
  • 心情日记
  • 英语文章
  • 范文大全
  • 作文大全
  • 新闻阅读
  • 当前位置: 山茶花美文网 > 人生哲理 > 正文

    【iOS开发基础:UITableView】培训app开发

    时间:2020-05-29来源:山茶花美文网 本文已影响 山茶花美文网手机站

    实现UITableView的Controller需要实现 < UITableViewDataSource, UITableViewDelegate > 这两个代理,具体就是要实现以下两个方法:

    - (NSInteger)tableView:(UITableView *)tableView

    numberOfRowsInSection:(NSInteger)section{

    return [model getRowCount];

    }

    //返回UITableView的行数

    - (UITableViewCell *)tableView:(UITableView *)tableView

    cellForRowAtIndexPath:(NSIndexPath *)indexPath

    {

    static NSString *CellIdentifier = @”Cell”;

    UITableViewCell *cell = [tableView

    dequeueReusableCellWithIdentifier:CellIdentifier];

    if (cell == nil) {

    cell = [[[UITableViewCell alloc]

    initWithFrame:CGRectZero

    reuseIdentifier:CellIdentifier] autorelease];

    }

    NSUInteger row = [indexPath row];

    cell.textLabel.text = [model getNameAtIndex:row];

    return cell;

    }

    //呈现UITableView的每一个Cell

    • 爱情文章
    • 亲情文章
    • 友情文章
    • 随笔
    • 哲理
    • 励志
    • 范文大全