【发布时间】:2011-10-08 15:03:58
【问题描述】:
我发现照片库图像存在问题。它第一次没有在我的视图中显示,第一次加载时图像视图是空白的。
因为我发现资源库块在另一个线程上工作。重新加载我的视图后,我可以看到所有图像。但是第一次图像视图是空白的。
谁能告诉我解决问题的好方法
它适用于捆绑图像。
有时控制台也会显示
由于程序接收到的信号:“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];
}
【问题讨论】:
-
很难阅读格式如此奇怪的代码。这段代码在哪里执行,这可能是这段代码失败的一个重要方面。
-
我在我的视图中添加了一个滚动视图。滚动视图包含 9 个 UiView,每个 UIView 包含一个图像视图。当主 UILoads(单击 RootView TableView 单元格时)我需要在 ScrollView 中显示 9 个 ImageView。第一次,9 个图像视图是空的。再次动态重新加载后,我可以看到所有图像
-
有时应用程序由于程序接收到的信号而崩溃:“0”。数据格式化程序暂时不可用,将在“继续”后重试。 (加载共享库“/Developer/usr/lib/libXcodeDebuggerSupport.dylib”时出现未知错误)
标签: objective-c xcode image ipad photolibrary