我正在开发一个应用程序,我希望在带有自定义单元格的UITableView中显示几乎与屏幕大小相同的图像.图像加载良好,有点慢,但加载,但当我在TableView中滚动时,它们出现在错误的单元格(例如Cell5中的Image1应该出现Image5)1或2秒后出现正确的图像.为了没有太多数据流量,我想到了像这样的"缓存"类似的URL /图像存储:
- (id) init
{
if (self = [super init]) {
self.cacheStoreDictionary = [NSMutableDictionary new];
}
return self;
}
- (void) startLoadingImageWithUrl:(NSString *)urlString forItem:(id)item
{
if (self.cacheStoreDictionary[urlString]) {
UIImage *image = self.cacheStoreDictionary[urlString];
[self.delegate lcCachedImageLoader:self didLoadImage:image forItem:item wasCacheHit:YES];
} else {
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{
NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:urlString]];
UIImage *image = [UIImage imageWithData:data];
dispatch_async(dispatch_get_main_queue(), ^{
[self.cacheStoreDictionary setObject:image forKey:urlString];
[self.delegate lcCachedImageLoader:self didLoadImage:image forItem:item wasCacheHit:NO];
});
});
}
}
Run Code Online (Sandbox Code Playgroud)
我需要的URL和其他数据我通过AFNetwork加载如下:
- (void)fetchTicketEvents
{
// Login URL
NSURL *eventsURL = [NSURL …Run Code Online (Sandbox Code Playgroud) 嗨首先,我必须承认我真的不明白整个Passbook主题是如何工作的.所以这是我的情况:我有一个后端系统,它创建.pkpass文件存储它们并创建一个URL.当我在浏览器中打开此URL时,它会直接开始下载传递文件.如何使用ios应用程序接收或打开此文件?
提前致谢.