使用来自lazytablevimage的UIWebView将xml url链接传递给视图?

时间:2013-04-19 22:39:12

标签: ios xml uitableview webview tableview

示例这是我的XML

<feed xmlns:im="http://itunes.apple.com/rss" xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
<entry>

<im:title>Como Una Virgen para Cristo</im:title>
<im:url>listindiario.com</im:url>

</entry>

一切都很完美......

但问题是当你按下称重传感器链接url打开另一个UIWebView视图时我该怎么做?

我正在使用故事板

这是一些代码: AppTableViewController.m

#import "AppTableViewController.h"
#import "AppRecord.h"
#import <SDWebImage/UIImageView+WebCache.h>
#import "CustomCell.h"
#import "WebView.h"
#import "ParseOperation.h"
@class WebView;
@implementation AppTableViewController
#pragma mark - Table view creation (UITableViewDataSource)

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section


{
    return [self.entries count];
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{


    static NSString *CellIdentifier = @"LazyTableCell";
    CustomCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];





    AppRecord *appRecord = (self.entries)[indexPath.row];
    cell.nameText.text = appRecord.appName;
    cell.detalleText.text = appRecord.artist;
    cell.durationText.text= appRecord.appDuration;
    cell.dateText.text= appRecord.appDate;

    [cell.myimage setImageWithURL:[NSURL URLWithString:appRecord.imageURLString]
      placeholderImage:[UIImage imageNamed:@"BackgorundLogoCell.png"]];


    cell.detalleText.text = appRecord.artist;

    return cell;


}

ParseOperation.m

#import "ParseOperation.h"
#import "AppRecord.h"
#import "TFHpple.h"
#import "TFHppleElement+KeyedSubcript.h"

@interface ParseOperation ()
@property (nonatomic, copy) ArrayBlock completionHandler;
@property (nonatomic, strong) NSData *dataToParse;
@end

@implementation ParseOperation
- (id)      initWithData:(NSData *)data
       completionHandler:(ArrayBlock)handler
{
    self = [super init];
    if (self != nil)
    {
        self.dataToParse = data;
        self.completionHandler = handler;
    }
    return self;
}
- (void)main
{
    NSMutableArray *workingArray = [NSMutableArray array];
    TFHpple *appParser = [TFHpple hppleWithXMLData:self.dataToParse];
    NSString *appXpathQueryString = @"//xmlns:entry";
    NSArray *appsArray = [appParser searchWithXPathQuery:appXpathQueryString];
    for (TFHppleElement *element in appsArray) {
        AppRecord *app = [[AppRecord alloc] init];
        app.appName = [[element firstChildWithTagName:@"title"] text];
        app.imageURLString = [[element firstChildWithTagName:@"image"] text ];
        app.artist = [[element firstChildWithTagName:@"pastor"] text];
        app.appDuration = [[element firstChildWithTagName:@"duration"] text];
        app.appDate = [[element firstChildWithTagName:@"date"] text];
        app.appUrl = [[element firstChildWithTagName:@"url"] text];
        [workingArray addObject:app];
    }
    self.completionHandler(workingArray);
    self.dataToParse = nil;
}

1 个答案:

答案 0 :(得分:0)

要在UITableView的任何单元格中进行触摸响应,您必须实现此方法....

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 

在此方法中,您可以初始化任何视图,并根据单元格将链接传递给此新视图。

要在webView中加载网页,您需要编写此内容...

 NSURL *url = [NSURL URLWithString:urlAddress];
 NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
[webView loadRequest:requestObj];