解决方案实现在UITableView中显示数据

发一下牢骚和主题无关:

    原问题来自于CSDN问答道频,更多解决方案见:http://ask.csdn.net/questions/2335

    问题述描:

    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.置设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]];
}

    
 

文章结束给大家分享下程序员的一些笑话语录: 自行车
一个程序员骑着一个很漂亮的自行车到了公司,另一个程序员看到了他,问 到,“你是从哪搞到的这么漂亮的车的?”
骑车的那个程序员说, “我刚从那边过来, 有一个漂亮的姑娘骑着这个车过来, 并停在我跟前,把衣服全脱了,然后对我说,‘你想要什么都可以’”。
另一个程序员马上说到, “你绝对做了一个正确的选择, 因为那姑娘的衣服你 并不一定穿得了”。

posted @ 2013-05-06 19:43  xinyuyuanm  阅读(191)  评论(0编辑  收藏  举报