从填充阵列的一个UITableView

编程入门 行业动态 更新时间:2024-10-28 02:24:54
本文介绍了从填充阵列的一个UITableView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我需要用下面的code我使用hpple解析HTML帮助。我需要利用数据帮助。

- (无效){什么NSData的* htmlData = [[NSString的stringWithContentsOfURL:[NSURL URLWithString:@www.objectgraph/contact.html]] dataUsingEncoding:NSUTF8StringEncoding];TFHpple * xpathParser = [[TFHpple页头] initWithHTMLData:htmlData];NSArray的*标题= [xpathParser搜索:@// H3]; //获取页面标题 - 这是XPath符号TFHppleElement *标题= [标题objectAtIndex:0];* NSString的myTitles = [标题内容]NSArray的*文章= [xpathParser搜索:@// H4]; //获取页面的文章 - 这是XPath符号TFHppleElement *文章= [文章objectAtIndex:0];* NSString的myArtical = [文章内容]

我想创建并从数组填充表标题然后可以点击桌子上的物品装入一个子视图应该相同指数显示相应的ARTICAL?

我想这样做编程或使用IB

任何人都可以提出一些样品code或A教程?

感谢。

解决方案

- (NSInteger的)的tableView:(UITableView的*)的tableView numberOfRowsInSection:(NSInteger的)部分{返回[标题计数]} - (UITableViewCell的*)的tableView:(UITableView的*)的tableView的cellForRowAtIndexPath:(NSIndexPath *)indexPath {        静态的NSString * MyIdentifier = @MyIdentifier        * UITableViewCell的细胞= [的tableView dequeueReusableCellWithIdentifier:MyIdentifier];        如果(细胞==零){            电池= [[[UITableViewCell的页头] initWithFrame:方法CGRectZero reuseIdentifier:MyIdentifier]自动释放];        }    cell.textLabel.text = [标题objectAtIndex:indexPath.row];        返回细胞;} - (无效)的tableView:(UITableView的*)的tableView didSelectRowAtIndexPath方法:(NSIndexPath *)indexPath {/ *这里弹出您与从数组索引indexpath.row数组对应值的子视图。* /}

I need help with the following code i am using hpple to parse html. and i need help utilizing the data.

-(void) whatever{ NSData *htmlData = [[NSString stringWithContentsOfURL:[NSURL URLWithString: @"www.objectgraph/contact.html"]] dataUsingEncoding:NSUTF8StringEncoding]; TFHpple *xpathParser = [[TFHpple alloc] initWithHTMLData:htmlData]; NSArray *titles = [xpathParser search:@"//h3"]; // get the page title - this is xpath notation TFHppleElement *title = [titles objectAtIndex:0]; NSString *myTitles = [title content]; NSArray *articles = [xpathParser search:@"//h4"]; // get the page article - this is xpath notation TFHppleElement *article = [articles objectAtIndex:0]; NSString *myArtical = [article content];

i want to create and populate a table from the array "titles" Then be able to click the item on the table to load a subview that should show the corresponding artical at the same index?

I'd like to do this programatically or using IB

can anyone suggest some sample code or a tutorial?

Thanks.

解决方案

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ return [titles count]; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ static NSString *MyIdentifier = @"MyIdentifier"; UITableViewCell *cell =[tableView dequeueReusableCellWithIdentifier:MyIdentifier]; if (cell == nil){ cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:MyIdentifier] autorelease]; } cell.textLabel.text = [titles objectAtIndex:indexPath.row]; return cell; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ /* here pop up Your subview with corresponding value from the array with array index indexpath.row ..*/ }

更多推荐

从填充阵列的一个UITableView

本文发布于:2023-08-05 21:42:07,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1308224.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:阵列   UITableView

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!