程序员iOS开发iOS Developer

UITableView(一)

2016-04-21  本文已影响117人  飞翔的道长

/**
 *  标记多少行数据
 *
 *  @param tableView tableView
 *  @param section   组号
 *
 *  @return 返回行数
 */
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 2;// 两条
}


/**
 *  每行如何显示
 *
 *  @param tableView tableView
 *  @param indexPath 
 *
 *  @return 每行的内容
 */
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [[UITableViewCell alloc]init];
        // initWithStyle:UITableViewCellStyleSubtitle 显示子标题
//    UITableViewCell *cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:nil];
    cell.textLabel.text = @"我是第一组";
    cell.imageView.image = [UIImage imageNamed:@"m_10_100"];//添加图片
    
    if(indexPath.section == 1)
    {
        cell.textLabel.text = @"我是第二组";
        cell.imageView.image = [UIImage imageNamed:@"m_13_100"];
    }
    
    if(indexPath.section == 2)
    {
        cell.textLabel.text = @"我是第三组";
        cell.imageView.image = [UIImage imageNamed:@"m_14_100"];
    }
    
    return  cell;
}

上一篇 下一篇

猜你喜欢

热点阅读