2010-08-12 8 views
1

회사 디렉토리의 사람 검색을 기반으로 한 표 셀에 이미지를 삽입하려고합니다. 이것은 꽤 쉽게 할 수 있지만 문제는 어떤 사람들은 그림이 없어서 자신의 조화를 보이지 않게하는 것입니다. 사진이없고 텍스트를 슬라이드하지 않으면 셀을 비워 두는 방법이 있습니까? 내 셀 구성은 다음과 같습니다.iPad 맞춤 테이블 셀 도움말

static NSString *CellIdentifier = @"Cell"; 

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
if (cell == nil) { 
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease]; 
} 

Person *aPerson = [appDelegate.people objectAtIndex:indexPath.row]; 

cell.textLabel.text = [NSString stringWithFormat:@"%@ %@", aPerson.first_name, aPerson.last_name]; 
cell.detailTextLabel.text = [NSString stringWithFormat:@"%@, %@, %@", aPerson.sso, aPerson.email, aPerson.business_name]; 


cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton; 


//trin the newlines out of file url 
NSString *trimmedPath = [aPerson.image_path stringByTrimmingCharactersInSet:[NSCharacterSet newlineCharacterSet]]; 

if ([trimmedPath length] != 0) { 
    //concat url and retrieve data 
    NSURL *url = [[NSURL alloc] initWithString:[NSString stringWithFormat:@"http://******.*****.com/%@", trimmedPath]]; 

    NSData *imgData = [NSData dataWithContentsOfURL:url]; 

    //Save into cell 
    UIImage *theImage = [UIImage imageWithData:imgData]; 
    cell.imageView.image = theImage; 
      return cell; 
} else { 
    return cell; 
} 

아이디어가 있습니까? 감사!

답변

2

단순한 디자인 아이디어처럼 : 물음표에서 공백까지 채울 수있는 기본 이미지를 넣을 수 있습니다.

+0

아, 네가 아는 것은 그렇게 단순하지만 실제로 효과가있을 것이다. 감사! – gabaum10