红桃J

用心写好每行完美的代码,远比写一堆更有价值

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

举一个炒鸡简单的例子:

1 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
2     NSString *cellIdentifier = @"ContactCell";
3     HMContactRecordTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
4 //    [cell setInof:nil];
5     cell.nameLabel.text = @"皮卡丘";
6     cell.addressLabel.text = @"四川省成都市";
7     return cell;
8 }

以上是使用静态例子的方法。

1 - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
2     return 20;
3 }

这时控制cell个数的函数,在这里写死,就20个。

在Identifier属性里,填上在上上个方法里的Identifier。

上上个方法里备注释掉的语句是写在自顶一个UITableViewCell类HMContactRecordTableViewCell中的方法。

- (void)setInof:(id)info {
    self.nameLabel.text = @"奥特曼";
    self.telLabel.text = @"15652962058";
    self.timeLabel.text = @"12:00";
    self.addressLabel.text = @"四川省成都市";
}

调用这个方法就可以实现设置了。

最后的效果图:

posted on 2014-10-23 18:57  红桃J  阅读(280)  评论(0编辑  收藏  举报