Advertisement
Guest User

Untitled

a guest
Jan 15th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. - (void)imagePickerController:(UIImagePickerController *)picker
  2. didFinishPickingMediaWithInfo:(NSDictionary *)info
  3. {
  4.     UIImage *image = (UIImage *) [info objectForKey:UIImagePickerControllerOriginalImage];
  5.    
  6.     attachment = [Utility resizeImg:image];
  7.    
  8.     [attachNewFileButton setImage:attachment forState:UIControlStateNormal];
  9.    
  10.     // get the ref url
  11.     NSURL *refURL = [info valueForKey:UIImagePickerControllerReferenceURL];
  12.    
  13.     // define the block to call when we get the asset based on the url (below)
  14.     ALAssetsLibraryAssetForURLResultBlock resultblock = ^(ALAsset *imageAsset)
  15.     {
  16.         ALAssetRepresentation *imageRep = [imageAsset defaultRepresentation];
  17.        
  18.         attachmentName = [imageRep filename];
  19.         [attachNewFileButton setTitle:attachmentName forState:UIControlStateNormal];
  20.         deleteNewAttachmentButton.hidden = NO;
  21.     };
  22.    
  23.     // get the asset library and fetch the asset based on the ref url (pass in block above)
  24.     ALAssetsLibrary* assetslibrary = [[ALAssetsLibrary alloc] init];
  25.     [assetslibrary assetForURL:refURL resultBlock:resultblock failureBlock:nil];
  26.    
  27.     [self dismissViewControllerAnimated:YES completion:nil];
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement