Created
August 6, 2014 00:27
-
-
Save yoshyosh/6d60983462561c9ca506 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { | |
NSURL *referenceURL = info[UIImagePickerControllerReferenceURL]; | |
//Initialize photo with referenceURL, get meta data etc | |
//[photo.location.latitude | |
//photo.location.longitude | |
//photo.venue | |
//photo.orientation | |
// | |
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init]; | |
[library assetForURL:referenceURL resultBlock:^(ALAsset *asset) { | |
ALAssetRepresentation *rep = [asset defaultRepresentation]; | |
NSDictionary *metadata = rep.metadata; | |
//Need some check for if location found/available | |
CLLocation *pickerLocation = [asset valueForProperty:ALAssetPropertyLocation]; | |
NSLog(@"%@",metadata); | |
//Will have to figure out location array | |
double latitude = pickerLocation.coordinate.latitude; | |
double longitude = pickerLocation.coordinate.longitude; | |
//If we cant get meta data, suggest that they pick from photo stream, give them a picture etc to show example | |
CGImageRef iref = [rep fullScreenImage]; | |
UIImage *resizedImage = [self resizeImage:[UIImage imageWithCGImage:iref] source:@"picker"]; | |
self.pickerImage = resizedImage; | |
if (rep.dimensions.width < rep.dimensions.height) { | |
[self setLocationLabelPortraitPosition]; | |
self.camera.imageOrientation = 3; | |
} else { | |
[self setLocationLabelLandscapeRightPosition]; | |
self.camera.imageOrientation = 1; | |
} | |
[picker dismissViewControllerAnimated:NO completion:^{ | |
// getLocationNameWithLatLong | |
[Venue getVenuesWithLatitude:latitude andLogitude:longitude completionHandler:^(NSArray *venues) { | |
Venue *venue = venues[0]; | |
self.venue = venue; | |
[self showEditControllerWithImage:self.pickerImage andOrientation:self.camera.imageOrientation andVenue:venue andLocation:self.locationArray]; | |
// Need to check current device orientation to reset label position, feel like this should fire on viewdid load | |
// self.venue needs to be reset as well | |
// self.locationArray too | |
[self orientationChanged:(NSNotification *)UIDeviceOrientationDidChangeNotification]; | |
}]; | |
}]; | |
} failureBlock:^(NSError *error) { | |
//error handling | |
}]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment