comment afficher une alerte lorsque l'utilisateur clique sur le bouton utilisé après la prise d'une photo à l'aide uiimagepicker?

StackOverflow https://stackoverflow.com/questions/1832459

Question

Je veux montrer une alerte lorsque l'utilisateur tire une image et cliquez sur l'utilisation étrange de button.It que dans l'iPhone OS 2.0 quand nous prendre une photo, il affiche un message de chargement, mais dans l'iPhone OS 3.0, il ne montre rien. Comment puis-je afficher une alerte est-il un moyen de fixer le processus de imagepicking? dans mon application il est parfois lent et parfois, il est vite que je ne l'ai pas comprendre cela yet.Does quelqu'un sait à ce sujet?

Était-ce utile?

La solution

Dans votre méthode « imagePickerController » vous allez vouloir afficher un UIAlertView. Ci-dessous, la méthode complète avec la création de UIAlertView.

Le UIAlertView sera affiché pendant toute la durée du temps qu'il faut pour enregistrer l'image à l'album photo.

Vous devrez également ajouter la méthode « didFinishSavingWithError »

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)selectedImage editingInfo:(NSDictionary *)editingInfo
{
  if(picker.sourceType == UIImagePickerControllerSourceTypeCamera)
  {
    saveImage = [[UIAlertView alloc] initWithTitle:@"Saving Image..." message:nil delegate:self cancelButtonTitle:nil otherButtonTitles:nil]; 

    UIActivityIndicatorView *waitView = [[[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge] autorelease];
    waitView.frame = CGRectMake(120, 50, 40, 40);
    [waitView startAnimating];

    [saveImage addSubview:waitView];
    [saveImage show]; 
    [saveImage release];

    UIImageWriteToSavedPhotosAlbum(selectedImage, self, @selector(image:didFinishSavingWithError:contextInfo:), nil);
  }

  [self dismissModalViewControllerAnimated:YES];
}

- (void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo
{
  // Was there an error?
  if (error == NULL)
   {
     NSLog(@"Image Saved");
     [saveImage dismissWithClickedButtonIndex:0 animated:YES]; 
   }
  else
   {
     // Error occured
   }
}
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top