Я пытаюсь вставить изображение в ячейку таблицы, базирующуюся от поиска человека в нашем каталоге компании. Это довольно легко сделать, но проблемой являются некоторые люди, не имеют изображений, таким образом, она отбрасывает их выравнивание. Там какой-либо путь состоит в том, чтобы иметь ячейку, сохраняют тот пробел места, если они не имеют изображения и не двигают текст? Это - то, на что похожа моя конструкция ячейки:
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;
}
Какие-либо идеи?Спасибо!
просто как простая дизайнерская идея: вы можете вставить изображение по умолчанию, начиная от вопросительного знака и заканчивая пустым пространством, чтобы удерживать пространство.