开发者社区> 问答> 正文

在UITableView中显示数据

NSArray中有如下数据。使用AFHTTPRequestOperation来获取结果,然后执行` [ListOfName addObject:
[responseData valueForKey:name]];,想要下面的结果显示在tableView`中,但是不知道怎么实现?

(
        (
        "Richard Conover",
        "Richard Conover",
        "Kaitlyn Matheson",
        "Andrea Wannemaker",
        "Andrea Wannemaker",
        test,
        james,
        test,
        gaurav,
        sdfsdfs
    )
)

如果用NSArray.count返回。如何在tableView中分开打印?

展开
收起
爵霸 2016-03-23 10:25:54 1646 0
1 条回答
写回答
取消 提交回答
  • 1.设置UITableViewdelegate,datasource

    self.tableView.delegate=self;
    self.tableView.datasource=self;

    2.实现协议方法

    -(NSInteger)numberOfSectionsInTableView {
         return 1;
    }
    
    -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection {
          return [ListOfName count];
    }
    
    -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
         static NSString *identifier=@"cellIdentifier";
         UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:identifier];
        if (cell==nil) {
              cell=[[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier] autorelease];
        }
    
        cell.textLabel.text=[ListObName objectAtIndex:[indexPath row]];
        return cell;
    }
    2019-07-17 19:10:25
    赞同 展开评论 打赏
问答分类:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载