Question

Est-il possible de désactiver l'aperçu de l'image après avoir pris une photo avec le UIImagePickerController? Je veux rejeter la ImagePicker dès que l'utilisateur appuie sur le bouton déclencheur.

Était-ce utile?

La solution

J'ai posé une question similaire

Ma solution a été de créer une vue personnalisée sur le dessus du UIImagePickerControllerView par défaut.

J'ai téléchargé l'exemple Réalité Augmentée

Ensuite, vous pouvez utiliser le OverlayView.m et OverlayView.h en les ajoutant à votre projet: Je pris la barre d'outils sélecteur de commande, sélecteur et overlayView global afin que je puisse y accéder partout dans le projet.

Dans votre ViewController.h

@class OverlayView;

@interface ViewController //bla bla...
{
UIImagePickerController * picker;
UIToolbar *toolBar;
OverlayView *overlayView; 
}

J'ai créé les commandes de la barre d'outils un bouton de la caméra et le bouton Annuler

// toolbar - handy if you want to be able to exit from the image picker...
            toolBar=[[[UIToolbar alloc] initWithFrame:CGRectMake(0, 480-55, 320, 55)] autorelease];
            toolBar.barStyle =  UIBarStyleBlackOpaque;
            NSArray *items=[NSArray arrayWithObjects:
                            [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel  target:self action:@selector(cancelPicture)] autorelease],
                            [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace  target:nil action:nil] autorelease],
                            [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCamera  target:self action:@selector(shootPicture)] autorelease],
                            [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace  target:nil action:nil] autorelease],
                            [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace  target:nil action:nil] autorelease],
                            nil];
            [toolBar setItems:items];

            // create the overlay view
            overlayView=[[[OverlayView alloc] initWithFrame:CGRectMake(0, 0, 320, 480-44)] autorelease];
            // important - it needs to be transparent so the camera preview shows through!
            overlayView.opaque=NO;
            overlayView.backgroundColor=[UIColor clearColor];

                    // parent view for our overlay
        UIView *parentView=[[[UIView alloc] initWithFrame:CGRectMake(0,0,320, 480)] autorelease];
        [parentView addSubview:overlayView];
        [parentView addSubview:toolBar];

        // configure the image picker with our overlay view
        picker=[[UIImagePickerController alloc] init];
        picker.sourceType = UIImagePickerControllerSourceTypeCamera;

        // hide the camera controls
        picker.showsCameraControls=NO;
        picker.wantsFullScreenLayout = YES;

Le procédé annuler

- (IBAction)cancel {
    // Don't pass current value to the edited object, just pop.
    [self.navigationController popViewControllerAnimated:YES];
}

Le (shootPictureMethod):

-(void) shootPicture {

    [picker takePicture];

}

Pour quitter sans montrer aperçu rejeter simplement la vue après avoir pris la photo dans la méthode didFinishPickingImage

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)img editingInfo:(NSDictionary *)editInfo 
{
//do whatever

[self dismissModalViewControllerAnimated:YES];
}
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top