콜백을 사용하여 "cellForRowAtIndexPath"이미지를로드 할 때 UITableView에 Asynchoronous GCD를 사용하고 있습니다. 내를 tableView에서다중 GCD를 사용하여 TableView에서 이미지로드
, 각 행은 (평균, 각 행에 난 asynchoronous GCD를 사용하여 두 이미지를로드 할 수있는) 2 생성물을 -> 다음과 같이 여기
내 코드 로드 이미지
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
//Some code to init CustomCell
//Load Label1
//Load Label2
//Load image1
if(product1.thumImgData != nil){
//Update image from datasource
} else{
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
NSData *imgData = [NSData dataWithContentsOfURL:[NSURL URLWithString:product1.thumImg]];
if (imgData) {
UIImage *image = [UIImage imageWithData:imgData];
if (image) {
dispatch_async(dispatch_get_main_queue(), ^{
CustomViewProductByCategory *updateCell = (id)[self.tvProduct cellForRowAtIndexPath:indexPath];
if (updateCell){
product1.thumImgData = imgData;
updateCell.imgProduct1.image = image;
[updateCell.indicatorProduct1 stopAnimating];
}
});
}
}
});
}
if(product2.thumImgData != nil){
//Update image from datasource
} else{
//load image2
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
NSData *imgData = [NSData dataWithContentsOfURL:[NSURL URLWithString:product2.thumImg]];
if (imgData) {
UIImage *image = [UIImage imageWithData:imgData];
if (image) {
dispatch_async(dispatch_get_main_queue(), ^{
CustomViewProductByCategory *updateCell = (id)[self.tvProduct cellForRowAtIndexPath:indexPath];
if (updateCell){
product2.thumImgData = imgData;
updateCell.imgProduct2.image = image;
[updateCell.indicatorProduct2 stopAnimating];
}
});
}
}
});
}
asynchoronous 내가 그렇게 때로는 cellForRowAtIndexPath 2 GCD를 사용하고의 때문에, 생각, 내가 어떤 이미지를로드 할 수 없습니다.
아무도이 문제를 해결하는 방법을 알고 있습니까? Tks 사전에.
동일한 문제가 있었는데 이미지 데이터의 크기가 얼마나 큽니까? 테이블 뷰 셀에서 사용할 작은 축소판 이미지를 만드는 것이 가장 좋습니다. – DogCoffee
서버에 작은 데이터를 보내달라고 요청했습니다. 그냥 80x80px –