views:

307

answers:

1

I want to show a alert when user shoots a picture and click on use button.It's strange that in iPhone OS 2.0 when we shoot a picture it shows a loading message,but in iphone os 3.0 it shows nothing. How do i show an alert also is there a way to fasten the imagepicking process? in my app sometimes it's slow and sometimes it's fast i haven't figure this out yet.Does someone knows about it?

A: 

In your method "imagePickerController" you're going to want to display a UIAlertView. Shown below is the the complete method with creation of UIAlertView.

The UIAlertView will be displayed for the length of time that it takes to save the image to the photo album.

You will also need to add the method "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
   }
}
Tammen Bruccoleri