UITableViewCell에서 비동기 적으로 서버에서로드 UIImages를 시도합니다. 내 코드는 시뮬레이터에서는 정상적으로 작동하지만 장치에서는 제대로 작동하지 않습니다. 내 코드는 다음과 같이, 시뮬레이터UIImage가 제대로 작동하지 않습니까?
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
IScopeCustomTableCell *cell = (IScopeCustomTableCell *)[tableView dequeueReusableCellWithIdentifier:CellClassName];
if (!cell){
NSArray *topLevelItems = [cellLoader instantiateWithOwner:self options:nil];
cell = [topLevelItems objectAtIndex:0];
}
cell.delegate = self;
cell.videoTitle.text = [[videoDataArray objectAtIndex:indexPath.row] objectForKey:@"VideoTitle"];
cell.videoLink = [[videoDataArray objectAtIndex:indexPath.row] objectForKey:@"VideoLink"];
cell.videoThumbnailImageLink = [[videoDataArray objectAtIndex:indexPath.row] objectForKey:@"VideoThumbnail"];
cell.videoThumbnail.tag = indexPath.row;
cell.tag = indexPath.row;
[cell.activityIndicator startAnimating];
NSInvocationOperation *operation = [[NSInvocationOperation alloc]
initWithTarget:self
selector:@selector(loadImage:)
object:cell];
[queue addOperation:operation];
return cell;
}
- (void)loadImage:(IScopeCustomTableCell *)cell {
NSLog(@"Image link :- %@", cell.videoThumbnailImageLink);
//NSData* imageData = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:cell.videoThumbnailImageLink]];
NSData* imageData = [NSData dataWithContentsOfURL:[NSURL URLWithString:cell.videoThumbnailImageLink]];
UIImage* image = [UIImage imageWithData:imageData];
cell.videoThumbnail.image = image;
[cell.activityIndicator stopAnimating];
[cell.activityIndicator removeFromSuperview];
//[self performSelectorOnMainThread:@selector(displayImage:) withObject:image waitUntilDone:NO];
}
상기 코드 미세하지만 장치에 becoz,있는 UIImage * 화상을 NSData loadImage GET 방법이 적절한 데이터를 포함하더라도의 (0X0) 널.
얼마나 많은 파일 크기가 서버에서 왔습니까 ??? – parag
@paragkavar, 20KB – Tirth
명백한 진술에 대해 사과 드려 죄송 합니다만, 기기가 웹에 액세스 할 수 있는지 이미 확인 했습니까? 또한 셀이 표시 될 때마다 스레드를 실행하는 것이 최선의 방법은 아닙니다. 비동기 적으로 이미지를로드하기 위해 웹에서 많은 자습서를 찾을 수 있습니다. – Leonardo