Iphone iPad自定义表格单元格帮助
我正在尝试根据公司目录中的人员搜索将图像插入表单元格。这是很容易做到的,但问题是有些人没有照片,所以这会使他们的路线偏离。如果他们没有图片,有没有办法让单元格保持空白,而不是将文本滑到上面?这就是我的手机结构:Iphone iPad自定义表格单元格帮助,iphone,objective-c,ipad,Iphone,Objective C,Ipad,我正在尝试根据公司目录中的人员搜索将图像插入表单元格。这是很容易做到的,但问题是有些人没有照片,所以这会使他们的路线偏离。如果他们没有图片,有没有办法让单元格保持空白,而不是将文本滑到上面?这就是我的手机结构: static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell ==
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;
}
有什么想法吗?谢谢 就像一个简单的设计思想:你可以放入一个默认的图像,从问号到空格都可以 啊,你知道吗,这很简单,但可能会奏效。谢谢