我有一个试图加载图像的UIImageView,如果它不存在,我打电话下载图像.下载图像后,将发送NSNotification,并将UIImageView.image设置为下载的图像.这是有效的,但是在设置图像后需要几秒钟才能在UIImageView中显示它.再次在图像下载后发送通知,因此延迟不是图像的下载.
这是通知:
- (void)recieveImageDownloadUpdate:(NSNotification *)notification {
if ([[item valueForKey:@"FlipBookPhotoID"] intValue] == imgView1.tag) {
// this loads the image if the tag on the UIImageView matches the notification update
imgView1.image = [Helpers getImageDownloadIfMissing:[[item valueForKey:@"PhotoName"] stringByReplacingOccurrencesOfString:@"_lg" withString:@""] withManufacturer:[item valueForKey:@"ManufacturerID"] withFlipBookID:[item valueForKey:@"FlipBookID"] withFlipBookPhotoID:[item valueForKey:@"FlipBookPhotoID"] shouldDownload:NO ];
}
}
Run Code Online (Sandbox Code Playgroud)
所有这些都在启用了分页的UIScrollView中使用,如何在通知后立即显示这些图像.
也许你没有在主线程中设置它.所有UI工作都需要在那里完成.
- (void)recieveImageDownloadUpdate:(NSNotification *)notification {
if ([[item valueForKey:@"FlipBookPhotoID"] intValue] == imgView1.tag) {
dispatch_async(dispatch_get_main_queue(), ^{
imgView1.image = [....]
});
}
Run Code Online (Sandbox Code Playgroud)
}
| 归档时间: |
|
| 查看次数: |
277 次 |
| 最近记录: |