0

例如这是我的 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;


}

解析操作.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;
}
4

1 回答 1

0

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

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

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

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

 NSURL *url = [NSURL URLWithString:urlAddress];
 NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
[webView loadRequest:requestObj];
于 2013-04-19T23:57:29.603 回答