Escolar Documentos
Profissional Documentos
Cultura Documentos
// ELCImagePickerDemoViewController.m
// ELCImagePickerDemo
//
// Created by ELC on 9/9/10.
// Copyright 2010 ELC Technologies. All rights reserved.
//
#import "ELCImagePickerDemoAppDelegate.h"
#import "ELCImagePickerDemoViewController.h"
#import <MobileCoreServices/UTCoreTypes.h>
@interface ELCImagePickerDemoViewController ()
@end
@implementation ELCImagePickerDemoViewController
- (IBAction)launchController
{
ELCImagePickerController *elcPicker = [[ELCImagePickerController alloc]
initImagePicker];
elcPicker.imagePickerDelegate = self;
- (IBAction)launchSpecialController
{
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
self.specialLibrary = library;
NSMutableArray *groups = [NSMutableArray array];
[_specialLibrary enumerateGroupsWithTypes:ALAssetsGroupSavedPhotos
usingBlock:^(ALAssetsGroup *group, BOOL *stop) {
if (group) {
[groups addObject:group];
} else {
// this is the end
[self displayPickerForGroup:[groups objectAtIndex:0]];
}
} failureBlock:^(NSError *error) {
self.chosenImages = nil;
UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@"Error" message:
[NSString stringWithFormat:@"Album Error: %@ - %@", [error localizedDescription],
[error localizedRecoverySuggestion]] delegate:nil cancelButtonTitle:@"Ok"
otherButtonTitles:nil];
[alert show];
- (void)displayPickerForGroup:(ALAssetsGroup *)group
{
ELCAssetTablePicker *tablePicker = [[ELCAssetTablePicker alloc]
initWithStyle:UITableViewStylePlain];
tablePicker.singleSelection = YES;
tablePicker.immediateReturn = YES;
// Move me
tablePicker.assetGroup = group;
[tablePicker.assetGroup setAssetsFilter:[ALAssetsFilter allAssets]];
- (BOOL)shouldAutorotateToInterfaceOrientation:
(UIInterfaceOrientation)toInterfaceOrientation
{
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
return YES;
} else {
return toInterfaceOrientation != UIInterfaceOrientationPortraitUpsideDown;
}
}
- (void)elcImagePickerController:(ELCImagePickerController *)picker
didFinishPickingMediaWithInfo:(NSArray *)info
{
[self dismissViewControllerAnimated:YES completion:nil];
[_scrollView addSubview:imageview];
workingFrame.origin.x = workingFrame.origin.x +
workingFrame.size.width;
} else {
NSLog(@"UIImagePickerControllerReferenceURL = %@", dict);
}
} else if ([dict objectForKey:UIImagePickerControllerMediaType] ==
ALAssetTypeVideo){
if ([dict objectForKey:UIImagePickerControllerOriginalImage]){
UIImage* image=[dict
objectForKey:UIImagePickerControllerOriginalImage];
[images addObject:image];
[_scrollView addSubview:imageview];
workingFrame.origin.x = workingFrame.origin.x +
workingFrame.size.width;
} else {
NSLog(@"UIImagePickerControllerReferenceURL = %@", dict);
}
} else {
NSLog(@"Uknown asset type");
}
}
self.chosenImages = images;
[_scrollView setPagingEnabled:YES];
[_scrollView setContentSize:CGSizeMake(workingFrame.origin.x,
workingFrame.size.height)];
}
- (void)elcImagePickerControllerDidCancel:(ELCImagePickerController *)picker
{
[self dismissViewControllerAnimated:YES completion:nil];
}
@end