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