在iPhone中顯示從ALAsset檢索到的URL圖像我使用ALAssetFramework訪問設備照片庫中的文件。到目前為止,我能夠訪問縮略圖并顯示它。我想在圖像視圖中顯示實際的圖像,但是我想不出如何做到這一點。我嘗試在ALAsset對象中使用URL字段,但沒有成功。有人知道怎么做嗎?下面是一些我能夠訪問縮略圖并將其放在表格單元格中的代碼:- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
//here 'asset' represents the ALAsset object
asset = [assets objectAtIndex:indexPath.row];
//i am accessing the thumbnail here
[cell.imageView setImage:[UIImage imageWithCGImage:[asset thumbnail]]];
[cell.textLabel setText:[NSString stringWithFormat:@"Photo %d", indexPath.row+1]];
return cell;}
3 回答
有只小跳蛙
TA貢獻1824條經驗 獲得超8個贊
ALAssetsLibraryAssetForURLResultBlock resultblock = ^(ALAsset *myasset){
ALAssetRepresentation *rep = [myasset defaultRepresentation];
CGImageRef iref = [rep fullResolutionImage];
if (iref)
{
UIImage *largeimage = [UIImage imageWithCGImage:iref scale:[rep scale] orientation:[rep orientation]];
[delegate hiresImageAvailable:large];
}};imageWIthCGImageorientationUIImage
[UIImage imageWithCGImage:iref scale:[rep scale] orientation:[rep orientation]];
[rep fullScreenImage][rep fullResolutionImage]
元芳怎么了
TA貢獻1798條經驗 獲得超7個贊
ALAssetsLibrary *assetsLibrary = [[ALAssetsLibrary alloc] init];[assetsLibrary assetForURL:self.selectedPhotos[i] resultBlock: ^(ALAsset *asset){
ALAssetRepresentation *representation = [asset defaultRepresentation];
CGImageRef imageRef = [representation fullResolutionImage];
if (imageRef) {
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
imageView.image = [UIImage imageWithCGImage:imageRef scale:representation.scale orientation:representation.orientation];
// ...
}} failureBlock: ^{
// Handle failure.}];failureBlocknil.
- 3 回答
- 0 關注
- 579 瀏覽
添加回答
舉報
0/150
提交
取消
