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