iOS 앱이 실행되면 셀에 아무것도 표시되지 않는 경우 이미지는 구문 분석에서 "파일"유형입니다. 나는 이것을 위해 스토리 보드를 사용하지 않으므로 imageView의 클래스를 PFImageView로 변경할 수 없습니다. 무엇이 빠졌습니까?
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath object:(PFObject *)object
{
static NSString *simpleTableIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTableIdentifier];
}
// Configure the cell
PFFile *thumbnail = [object objectForKey:@"logo"];
PFImageView *thumbnailImageView = (PFImageView*)[cell viewWithTag:100];
thumbnailImageView.image = [UIImage imageNamed:@"placeholder.png"];
thumbnailImageView.file = thumbnail;
[thumbnailImageView loadInBackground];
cell.textLabel.text = [object objectForKey:@"name"];
cell.detailTextLabel.textColor=[UIColor lightGrayColor];
cell.backgroundColor = [UIColor clearColor];
thumbnailImageView=[[PFImageView alloc] initWithFrame:CGRectMake(9, 9, 30, 30)];
[thumbnailImageView setBackgroundColor:[UIColor clearColor]];
[cell.contentView addSubview:thumbnailImageView];
return cell;
}
미리 감사드립니다!
이미지를 볼 수없는 이유는 파싱에서 데이터를 얻기 전에 백그라운드에서로드하고 설정하기 때문이라고 생각합니다. 다음과 같이 시도해 볼 수 있습니까?
// Set placeholder to show before image finishes loading
PFImageView *thumbnailImageView = (PFImageView*)[cell viewWithTag:100];
thumbnailImageView.image = [UIImage imageNamed:@"placeholder.png"];
PFFile *thumbnail = [object objectForKey:@"logo"];
[thumbnailImageView setFile:thumbnail];
[thumbnailImageView loadInBackground:^(UIImage *image, NSError *error) {
if (!error) {
// Configure your image view in here
imageView = [[UIImageView alloc] initWithFrame:CGRectMake(9, 9, 30, 30)];
[imageView setBackgroundColor:[UIColor clearColor]];
[imageView setImage:image];
[cell.contentView addSubview:imageView];
}
}];
이 라인을 따라 무언가를 시도하십시오.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다