In meinem RSS-Feed app, ich Parse Bilder mit NSXMLParser durch die didStartElement Methode eingeben:SDWebImage nicht geladen Bild von URL in UITableViewCell
If ([element isEqualToString: @ "item"]) {
Item = [[NSMutableDictionary alloc] init];
Title = [[NSMutableString alloc] init];
Link = [[NSMutableString alloc] init];
PubDate = [[NSMutableString alloc] init];
ImageUrl = [[NSMutableString alloc] init];
}
If ([element isEqualToString: @ "enclosure"]) {
NSString * name = [attributeDict objectForKey: @ "url"];
NSLog (@ "The URL is:% @", name);
}
Und in der didEndElement Methode:
If ([elementName isEqualToString: @ "item"]) {
[Item setObject: title forKey: @ "title"];
[Item setObject: link forKey: @ "link"];
[Item setObject: pubDate forKey: @ "pubDate"];
[Item setObject: imageUrl forKey: @ "url"];
[Feeds addObject: [item copy]];
}
Ok. Das funktioniert, die Links habe ich alle.
Jetzt möchte ich diese URLs in Zellen in meinem UITableView laden. Also habe ich den 'SDWebImage' Pod benutzt.
Im cellForRowAtIndexPath Methode ich habe:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath];
cell.textLabel.text = [[feeds objectAtIndex:indexPath.row] objectForKey: @"title"];
cell.textLabel.numberOfLines = 0;
[cell.textLabel setLineBreakMode:NSLineBreakByWordWrapping];
cell.detailTextLabel.text = [[feeds objectAtIndex:indexPath.row] objectForKey: @"pubDate"];
NSString *str = [[feeds objectAtIndex:indexPath.row] objectForKey: @"pubDate"];
cell.detailTextLabel.text = str;
NSString * string = [[feeds objectAtIndex:indexPath.row] objectForKey: @"url"];
NSLog(@"THE URL IS: %@", string);
[cell.imageView sd_setImageWithURL:[NSURL URLWithString:string] placeholderImage:[UIImage imageNamed:@"placeholder.gif"]];
return cell;
}
Aber nichts passiert. Das ist meine derzeitige Situation.
Wie beheben zu?
Könnten Sie 'string's Wert und' [NSURL URLWithString: string] 'Wert? Die URL ist wahrscheinlich – nathan
@nathan yep. Ich löse dieses Problem, aber jetzt habe ich ein anderes Problem: Die Bilder werden gesehen, aber wenn ich auf ein Bild klicke, ändert es seine Größe und wird länger..Warum? Schauen Sie http://imgur.com/YhSUiBL – Taprolano
Nein, Nein, ich habe einfache Bilder .jpg von der URL – Taprolano