이미지가로드되어 있어도 이미지가 표시되지 않는 문제가 있습니다. 나는이 여러 가지 다른 방법과 같은 결과를 시도했다 ... 이미지가 없다. 나는 스토리 보드에 지정된 크기와 색상 인 흰색 직사각형을 얻습니다. popover에서 올바른 수의 사각형을 얻습니다. 로그에는 이름과 ID가 올바르게 표시됩니다.UICollectionView 이미지가 표시되지 않습니다.
배열을 직접 호출하면 동일한 결과가 나타납니다. 흰색 직사각형.
내 대상은 iOS7입니다. Xcode 5.0.2 실행. 이미지는 SQL 데이터베이스에서옵니다. 이것은 전체 iOS7로 업데이트하고 UICollectionView에 대한 사용자 정의 그리드 레이아웃을 교체하고있는 라이브 앱입니다. CollectionViewController를 사용하여 UIButton을 통해 액세스되는 NavigationController에 포함됩니다. 보시다시피 맞춤 셀은 없습니다. 이미지는 팝 오버에 표시되며 사용자가 기본보기의 배경을 변경하도록 선택할 수 있습니다.
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"BckgndCell" forIndexPath:indexPath];
NSDictionary * tempDict = [_arrayOfBckgnds objectAtIndex:indexPath.row];
NSNumber *buttonTagNumber = (NSNumber *)[tempDict objectForKey:@"id"];
int buttonTag = [buttonTagNumber intValue];
NSString *tempImage = [tempDict objectForKey:@"fileName"];
NSLog(@"Filename: %@", tempImage);
NSLog(@"ButtonTagNumber: %@", buttonTagNumber);
UIImageView *image = [[UIImageView alloc]init];
image.image = [UIImage imageNamed:tempImage];
NSLog(@"Image.image: %@", image.image);
// needed for selecting the background in didSelectItemAtIndexPath
_bgtag = buttonTag;
return cell;
}
실제로 cellForItemAtIndexPath 방법에서 BackgroundCell (뜨아)을 명명하고 이미지를 설정 BackgroundCell 제어기 작은 생성 방법 포함 픽스.
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
BackgroundCell *cell = (BackgroundCell *)[collectionView dequeueReusableCellWithReuseIdentifier:@"BckgndCell" forIndexPath:indexPath];
NSDictionary * tempDict = [_arrayOfBckgnds objectAtIndex:indexPath.row];
NSNumber *buttonTagNumber = (NSNumber *)[tempDict objectForKey:@"id"];
int buttonTag = [buttonTagNumber intValue];
NSString *tempImage = [tempDict objectForKey:@"fileName"];
[cell setImage:[UIImage imageNamed:tempImage]];
// needed for selecting the background in didSelectItemAtIndexPath
_bgtag = buttonTag;
return cell;
}
주 셀 코드;
- (id)initWithFrame:(CGRect)frame
{
_backgroundImage = [[UIImageView alloc] initWithFrame:self.contentView.bounds];
[self.contentView addSubview:_backgroundImage];
if (self) {
// Initialization code
}
return self;
}
-(void)setImage:(UIImage *)image
{
_backgroundImage.image = image;
}
나는 지금 보여주는 이미지가 있습니다 ... 다른 작업을 위해 오랜 휴식을 취했습니다. 중요한 것은 셀 컨트롤러와 몇 가지 다른 것들을 호출하는 것입니다. 내 수정 프로그램이 위에 추가되었습니다. –