이렇게 커스텀 셀을 만든후
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
BoardCustomCell *cell = (BoardCustomCell *)[tableView dequeueReusableCellWithIdentifier:BoardCustomCellIdentifier];
// NSUInteger row = indexPath.row;
if(cell == nil)
{
cell = [BoardCustomCell cellWithNib];
}
NSMutableDictionary* commentData = [commentDataArray objectAtIndex:indexPath.row];
cell.contentLabel.text = [commentData objectForKey:@"CmtContent"];
cell.memberNameLabel.text = [commentData objectForKey:@"MemberName"];
cell.dateLabel.text = [commentData objectForKey:@"CreateDate"];
cell.memberLevelLabel.text = [commentData objectForKey:@"PntSumLv"];
cell.memberPointLabel.text = [commentData objectForKey:@"ReCmdCount"];
//image 나중에 주소를 plist에 넣자
NSString* imageUrl= [NSString stringWithFormat:@"http://주소/%@",[commentData objectForKey:@"MemberPhoto"]];
if ([commentData objectForKey:@"MemberPhoto"] == nil)
{
imageUrl= [NSString stringWithFormat:@"http://주소/default_profileImg_small.gif"];
}
// UIImage* memberPhotoImage= [[UIImage alloc]initWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:imageUrl]]];
// UIImage* memberPhotoImage= [[UIImage alloc]initWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:imageUrl]]];
[cell performSelectorInBackground:@selector(setImageUrl:) withObject:imageUrl];
// NSURL *url = [NSURL URLWithString:imageUrl];
// NSData *data = [NSData dataWithContentsOfURL:url];
// UIImage *memberPhotoImage = [[UIImage alloc] initWithData:data];
//
// [cell.memberPhotoImage setImage:memberPhotoImage];
// [memberPhotoImage release];
return cell;
}
주석 처리한 부분으로 이미지를 처리 했는데 느려서
[cell performSelectorInBackground:@selector(setImageUrl:) withObject:imageUrl];
이렇게 cell에서 이미지 처리를 백그라운드로 돌렸다.
cell 에서 구현한 소스는 이렇다.
-(void) setImageUrl:(NSString *)urlString
{
NSAutoreleasePool* pool = [NSAutoreleasePool new];
NSURL *url = [NSURL URLWithString:urlString];
NSData *data = [NSData dataWithContentsOfURL:url];
UIImage *img = [[[UIImage alloc] initWithData:data] autorelease];
[self.memberPhotoImage setImage:img];
[pool release];
}
'iPhone App' 카테고리의 다른 글
[iphone] 발전(업그레이드)된 XML Parser 사용하기 (0) | 2011.09.21 |
---|---|
[iphone] 데이터(XML)를 Post 방식으로 받아서 처리(WCF Rest) (0) | 2011.09.19 |
[iphone] table selection 안되게 하기 Disable (0) | 2011.09.19 |
[iphone] plist에 배열 저장/ 읽기 (0) | 2011.09.08 |
[iphone] URL 인코딩 (1) | 2011.09.08 |