ImageDemo 템플릿을 사용하고 있는데 이미지 묶음의 이미지를 코딩하면 작동하지만 앱에서 만든 디렉토리에서 이미지를로드하면로드가 없습니다. .iPad AQGridView가 묶음으로 내 UIImages를 표시하지 않습니다.
코드 : 나는 내 응용 프로그램에서 다른 장소에있는 모든 이상을 사용하기 때문에 나는이 일을 알고있는 이미지 데이터를 끌어 사용하고 그리고 난에 속성을 설정할 때이 전무를 확인하고
- (AQGridViewCell *) gridView: (AQGridView *) aGridView cellForItemAtIndex: (NSUInteger) index
{
static NSString * PlainCellIdentifier = @"PlainCellIdentifier";
AQGridViewCell * cell = nil;
ImageDemoGridViewCell * plainCell = (ImageDemoGridViewCell *)[aGridView dequeueReusableCellWithIdentifier: PlainCellIdentifier];
if (plainCell == nil)
{
plainCell = [[[ImageDemoGridViewCell alloc] initWithFrame: CGRectMake(0.0, 0.0, 200.0, 150.0)
reuseIdentifier: PlainCellIdentifier] autorelease];
plainCell.selectionGlowColor = [UIColor lightGrayColor];
}
NSString *fileName = [NSString stringWithFormat:@"%@/%@_tn.jpg",[manufacturerID stringValue], [[[self.collectionItems objectAtIndex:index] valueForKey:@"PhotoName"] stringByReplacingOccurrencesOfString:@" " withString:@"%20"]];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsPath = [paths objectAtIndex:0];
NSString *savePath =[documentsPath stringByAppendingPathComponent:fileName] ;
NSData *imageData = nil;
BOOL fileExists = [[NSFileManager defaultManager] fileExistsAtPath:savePath];
if (fileExists) {
imageData = [NSData dataWithContentsOfFile:savePath];
} else {
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"NoImageAvailableThumbNail" ofType:@"png"];
imageData = [NSData dataWithContentsOfFile:filePath];
}
UIImage *myImage = [UIImage imageWithData:imageData];
NSLog(@"%@", myImage);
if (myImage==nil) {
NSLog(@"NO IMAGE");
}
plainCell.image = myImage;
cell = plainCell;
return (cell);
}
I 코드 AQGridViewCell :
- (void) setImage: (UIImage *) anImage
{
_imageView.image = anImage;
[self setNeedsLayout];
}
응답 해 주셔서 감사 드리며, 로깅을 추가하고 이미지를 얻습니다. 보여줘. 어딘가에 어리석은 짓을 했음에 틀림 없어. 계속보고있어. 고마워. –
Slee
여전히 여기에 붙어있어, 나는 UIImage가 만들어지고 전달 된 것을 압니다. - 나는 그것들이 테스트로서 반복 될 때 메인 뷰에 추가했고, 그들은 확실히로드되었습니다. 번들에 포함 된 이미지를로드 할 수 있습니다. URL에 포함 된 위치가 없습니다. 당신이 다른 무엇을 생각할 수 있다면, 나는 그것을 감사 할 것입니다 - 도움을 주셔서 감사합니다. – Slee
확인해야 할 것은 이미지보기의 프레임이 빈 rect (즉 너비/높이가 0.0)가 아니라는 것입니다. 그것은'-layoutSubviews'에서 업데이트 될 것이므로, 먼저 거기에 체크하십시오. 또한 반환 된 UIImage가 공백 또는 nil 크기 (0.0x0.0)인지 확인하여 같은 종류의 문제를 일으킬 수 있습니다. –