eXit_door 2013-05-06 02:52 采纳率: 0%
浏览 4116
已采纳

在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中分开打印?

  • 写回答

1条回答

  • ReyZhang 移动开发领域新星创作者 2013-05-06 03:09
    关注

    1.设置UITableView的delegate,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;
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮