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