Skip to content

Instantly share code, notes, and snippets.

@goshmx
Last active August 29, 2015 14:14
Show Gist options
  • Save goshmx/bcf4a4125c01cb6f04e8 to your computer and use it in GitHub Desktop.
Save goshmx/bcf4a4125c01cb6f04e8 to your computer and use it in GitHub Desktop.
Funciones para trabajar con la libreria de la camara
alert = [[UIAlertView alloc] initWithTitle:@"Fotografia"
message:@"Que desea hacer?"
delegate:self
cancelButtonTitle:@"Cancelar"
otherButtonTitles:@"Camara", @"Carrete", nil];
[alert show];
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if(buttonIndex == 0)
{
NSLog(@"Cancelar");
}
else if(buttonIndex == 1)
{
NSLog(@"Camara");
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.allowsEditing = YES;
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
[self presentViewController:picker animated:YES completion:NULL];
}
else if(buttonIndex == 2)
{
NSLog(@"Carrete");
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.allowsEditing = YES;
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentViewController:picker animated:YES completion:NULL];
}
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
UIImage *chosenImage = info[UIImagePickerControllerEditedImage];
self.inputFoto.image = chosenImage;
[picker dismissViewControllerAnimated:YES completion:NULL];
}
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker {
[picker dismissViewControllerAnimated:YES completion:NULL];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment