Uploaded on

 

More in: Technology , Business
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
188
On Slideshare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
1
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Capturar imágenes desde la cámara del iPhoneUtilizaremos el controlador UIImagePickerController paraacceder a las imágenes guardadas en el dispositivo o capturarimágenes desde un iPhone.
  • 2. UIImagePickerController en acción Crear un nuevo proyecto en Xcode de tipo “View-Based Application”
  • 3. Agregar los siguientes elementos en “NombreAppViewController.h”:@interface CamAppViewController : UIViewController<UIImagePickerControllerDelegate, UINavigationControllerDelegate> {UIImageView *imagenView;UIButton *abrirGaleria;UIButton *tomarFoto;}
  • 4. @property (nonatomic, retain) IBOutlet UIImageView *imagenView;@property (nonatomic, retain) IBOutlet UIButton *abrirGaleria;@property (nonatomic, retain) IBOutlet UIButton *tomarFoto;- (IBAction)abrirGaleria:(id)sender;- (IBAction)tomarFoto:(id)sender;
  • 5. Abrir el archivo “NombreAppViewController.xib” (Interface Builder) y agregar 1 UIImageView y 2 UIButton
  • 6. Desde el Connections Inspector enlazar los elementos creados en Interface Builder con Xcode:
  • 7. #import “CamAppViewController.h”@implementation CamAppViewController@synthesize imagenView, abrirGaleria, tomarFoto;- (IBAction)abrirGaleria:(id)sender{// Inicia el ControladorUIImagePickerController * picker = [[UIImagePickerController alloc] init];// Define el Delegatepicker.delegate = self;// Establece el origen de la imagenpicker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;// Agrega la vista del controlador a la pantalla[self presentModalViewController:picker animated:YES];}- (IBAction)tomarFoto:(id)sender{UIImagePickerController * picker = [[UIImagePickerController alloc] init];
  • 8. Compilar y ejecutar: