이 tableView가 있고 사용자 지정 방식으로 셀을 작성하려고합니다. 내가하는 일은 셀에 하위 뷰를 추가하는 것입니다. 대리자의 스레드 안에 내 셀을 작성하는 방법은 무엇입니까?
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *cellIdentifier = @"cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if(cell == nil)
{
cell=[[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier] autorelease];
}
else
{
UIImageView* img=[UIImage imageNamed:@"abc.png"];
[cell addSubview:img];
//processing the final cell takes time!
}
return cell;
}
그러나, 일부 과민 프레임 레이트 테이블의 응답에 영향을주지 않기 때문에, 나는 스레드로 셀의 모든 창조를 전달하고 싶습니다. 그 동안 잠시 동안 어떤 종류의 이미지를 넣고 싶습니다. 스레드가 완료되면
cell
이 최종 셀로 업데이트됩니다.
정상적인 방법입니까?
그렇다면 스레드에서 셀을 어떻게 업데이트합니까?
모든 변수를 __block으로 정의해야합니까? 스레드에 들어가기 전에?
의 이미지 크기가 큽니까? 스레드에서 셀을 업데이트 할 수 없습니다. 메인 스레드에서 이것을 미리 만들어야하지만 여전히 백그라운드 스레드에서 임의의 조작을 수행하고 메인 스레드에서 업데이트를 호출 할 수 있습니다. – Ashim
http://stackoverflow.com/questions/8087010/loading-image-in-uitableviewcell-asynchronously –
새 XIB를 만들고 UITableViewCell을 끌어다 추가하십시오. 그런 다음 사용자 정의하십시오. 가장 좋은 방법입니다. –