我有一个 RSS 提要,其中包含照片的标题 en url,我想在这些图片中构建。做这个的最好方式是什么?我使用 MWPhotoBrowser 并且插入照片的方式是:
self.photos = [NSMutableArray array];
[photos addObject:[MWPhoto photoWithFilePath:[[NSBundle mainBundle] pathForResource:@"photo2l" ofType:@"jpg"]]];
[photos addObject:[MWPhoto photoWithURL:[NSURL URLWithString:@"http://farm4.static.flickr.com/3629/3339128908_7aecabc34b.jpg"]]];
[photos addObject:[MWPhoto photoWithURL:[NSURL URLWithString:@"http://farm4.static.flickr.com/3590/3329114220_5fbc5bc92b.jpg"]]];
如何使用 RSS 做到这一点?
谢谢!
最佳答案
如果您想从 RSS 提要创建照片查看器,我建议查看 MWFeedParser .您可以轻松获取每个项目的标题和 url,并根据需要显示它们。
1 - 使用 MWFeedParser,解析您的提要:
//feedURL would be your Photo RSS Feed
feedParser = [[MWFeedParser alloc] initWithFeedURL:feedURL];
2 - 在 MWFeedParser 委托(delegate)方法 didParseFeedItem 中,将项目的链接添加到您的照片数组:
-(void)feedParser:(MWFeedParser *)parser didParseFeedItem:(MWFeedItem *)item{
if (item) [photos addObject:[MWPhoto photoWithURL:[NSURL URLWithString:item.link]]];
}
现在照片数组包含了您所有的 MWPhoto,您可以对它们做任何您想做的事情!
关于带有 RSS 的 iOS 照片查看器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14964631/