2009-06-16 26 views

Respuesta

37

Este tutorial lo explica: http://www.musicalgeometry.com/?p=821

Sólo tiene que añadir UIImage en la vista de superposición en lugar de la zona roja se muestra en el tutorial.

+2

+1, esta es claramente la mejor respuesta. Si no me equivoco, se agregó cameraOverlayView en el 3.1 SDK. – Henning

+0

Hola, yo también necesitaría la información, pero el enlace no funciona. ¿Hay otros tutoriales? Gracias –

+0

@ dtt101: ¡Tu enlace ya no existe! : No encontrado – Momi

3

Puede agregar el UIImageView como una subvista de la ventana principal directamente en lugar del UIImagePicker, puede funcionar mejor. Solo asegúrese de agregarlos en el orden correcto, o llame al

[window bringSubviewToFront:imageView]; 

cuando la cámara está activa.

Si desea manejar toques en la UIImageView sólo podría añadir el UIImageView como subvista de una pantalla completa normalidad View con un fondo transparente, y añadir que a la ventana en su lugar, con un UIViewController subclase normal, que pueda usar para manejar los eventos táctiles.

2

ver la vista superposición cámara (disponible en 3.1 y posteriores)

@property(nonatomic, retain) UIView *cameraOverlayView 
10

Para su archivo de implementación:

- (IBAction)TakePicture:(id)sender { 

    // Create image picker controller 
    UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init]; 

    // Set source to the camera 
    imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera; 

     // Delegate is self 
     imagePicker.delegate = self; 

     OverlayView *overlay = [[OverlayView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];  

     // Insert the overlay: 
     imagePicker.cameraOverlayView = overlay; 

     // Allow editing of image ? 
     imagePicker.allowsImageEditing = YES; 
     [imagePicker setCameraDevice: 
     UIImagePickerControllerCameraDeviceFront]; 
     [imagePicker setAllowsEditing:YES]; 
     imagePicker.showsCameraControls=YES; 
     imagePicker.navigationBarHidden=YES; 
     imagePicker.toolbarHidden=YES; 
     imagePicker.wantsFullScreenLayout=YES; 

     self.library = [[ALAssetsLibrary alloc] init]; 

     // Show image picker 
     [self presentModalViewController:imagePicker animated:YES]; 
    } 

hacer una clase UIView y añadir este código

- (id)initWithFrame:(CGRect)frame 
    { 
     self = [super initWithFrame:frame]; 
     if (self) { 
      // Initialization code 


      // Clear the background of the overlay: 
      self.opaque = NO; 
      self.backgroundColor = [UIColor clearColor]; 

      // Load the image to show in the overlay: 
      UIImage *overlayGraphic = [UIImage imageNamed:@"overlaygraphic.png"]; 
      UIImageView *overlayGraphicView = [[UIImageView alloc] initWithImage:overlayGraphic]; 
      overlayGraphicView.frame = CGRectMake(30, 100, 260, 200); 
      [self addSubview:overlayGraphicView]; 

     } 
     return self; 
    } 
Cuestiones relacionadas