0
我发现照片库图像存在问题。它在我的视图中不显示第一次,图像视图在首次加载时为空白。延迟加载PhotoLibrary图像
因为我发现资产库块在另一个线程上工作。重新加载我的视图后,我可以看到所有的图像。但是,第一次图像视图是空白的。
任何一个可以告诉我一个很好的方法来处理它与捆绑的图像工作的问题
。
还有些时候控制台显示,由于节目的接收信号
应用程序崩溃:“0”。数据格式化程序暂时不可用,将在“继续”之后重新尝试。 (未知的错误载入共享库“/Developer/usr/lib/libXcodeDebuggerSupport.dylib”)
我的代码:
for (int j = 0; j<9; j++)
{
//allocating View
UIView *smallView = [[UIView alloc] initWithFrame:CGRectMake(xCordImage, yCordImage, 200, 190)];
// allocating ImageView
imageViewTopic = [[[UIImageView alloc] init] autorelease];
typedef void (^ALAssetsLibraryAssetForURLResultBlock)(ALAsset *asset);
typedef void (^ALAssetsLibraryAccessFailureBlock)(NSError *error);
ALAssetsLibraryAssetForURLResultBlock resultblock = ^(ALAsset *myasset)
{
ALAssetRepresentation *rep = [myasset defaultRepresentation];
CGImageRef iref = [rep fullResolutionImage];
UIImage *images;
if (iref) {
images = [UIImage imageWithCGImage:iref];
}
else {
images = [UIImage imageNamed:@"Nofile.png"];
}
imageViewTopic .image = images ;
};
ALAssetsLibraryAccessFailureBlock failureblock = ^(NSError *myerror)
{
imageViewTopic .image = [UIImage imageNamed:@"Nofile.png"];
NSLog(@"booya, cant get image - %@",[myerror localizedDescription]);
};
NSString *string ;
MyClass *obj = [imageFileNameArray objectAtIndex:j];
**//obj.fileName contains ALAsset URL of a Image**
string = obj.fileName;
NSURL *asseturl = [NSURL URLWithString:string];
ALAssetsLibrary* assetslibrary = [[[ALAssetsLibrary alloc] init] autorelease];
[assetslibrary assetForURL:asseturl resultBlock:resultblock
failureBlock:failureblock];
imageViewTopic.userInteractionEnabled = YES;
imageViewTopic.frame = CGRectMake(0,0, 200, 150);
[currentView addSubview:scroller];
**// adding the imageView to View**
[smallView addSubview:imageViewTopic];
[myView addSubview:smallView];
[scroller addSubview:myView];
}
很难看到你的代码格式很奇怪。该代码在哪里执行,这可能是此代码失败的一个重要方面。 – EricLeaf
我在我的视图中添加了滚动视图。滚动视图包含9个UiView,每个UIView包含一个图像视图。当主要的UILoads(当点击RootView TableView单元格时),我需要在ScrollView中显示9个ImageViews。第一次,9个imageViews是空的。在动态重新加载后,我可以看到所有图像 – sham
,并且由于程序接收信号:“0”,有时应用程序崩溃。 数据格式化程序暂时不可用,将在“继续”后重新尝试。 (未知错误加载共享库“/Developer/usr/lib/libXcodeDebuggerSupport.dylib”) – sham