使用uiimagepicker拍摄图片后用户单击“使用"按钮时如何显示警报? [英] how to show a alert when user click on use button after shooting a picture using uiimagepicker?

查看:50
本文介绍了使用uiimagepicker拍摄图片后用户单击“使用"按钮时如何显示警报?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在用户拍摄图片并单击使用"按钮时显示警报.奇怪的是,在iPhone OS 2.0中,当我们拍摄图片时它显示加载消息,但在iPhone OS 3.0中却什么也没有显示. 我如何显示警报,还有没有办法加快图像拾取过程?在我的应用中,有时速度很慢,有时速度很快,我还没有弄清楚.有人知道吗?

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?

推荐答案

在您的方法"imagePickerController"中,您将要显示UIAlertView.下面显示的是创建UIAlertView的完整方法.

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

UIAlertView将显示将图像保存到相册所需的时间.

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

您还需要添加方法"didFinishSavingWithError"

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
   }
}

这篇关于使用uiimagepicker拍摄图片后用户单击“使用"按钮时如何显示警报?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆