时间:2010-07-24 01:59:43

标签: iphone uiimage ios4 photo

3 个答案:

答案 0 :(得分:1)

答案 1 :(得分:1)

实际上,我发现没有更好的方法在我自己的Controller中显示整个图像。 我调整流量以符合我的要求。

 - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage: (UIImage *)image editingInfo:(NSDictionary *)editingInfo{

 // Transform image to NSData
 NSData *imageData = UIImagePNGRepresentation(image);

 // Create your path with Customized file-name   
 NSString *paths=NSHomeDirectory();   
 NSString *filename=@"XXXX.png";
 NSString *save=[paths stringByAppendingPathComponent:filename];   

 [imageData writeToFile:save atomically:NO];   

 [picker dismissModalViewControllerAnimated:YES];  

}

当用户点击缩略图时,会发生此方法。如果你想进行多选,我的解决方案是使用 NSOperation 来处理文件保存,它仍然需要用户点击缩略图。
顺便说一下,在UIImagePNGRepresentation(图片)之后,它可能需要缩放照片图像,原始图像(1200x1600)差不多300Kb

答案 2 :(得分:0)

使用这两种方法加载照片表单设备。

-(void)takePhoto:(id)sender
 {
  UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];

  //Use camera if device has one otherwise use photo library
  if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
   {
     [imagePicker setSourceType:UIImagePickerControllerSourceTypeCamera];
   }
  else
  {
    [imagePicker setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
   }

   [imagePicker setDelegate:self];

   //Show image picker
   [self presentModalViewController:imagePicker animated:YES];
   //Modal so we wait for it to complete
   [imagePicker release];
     }

  //********** RECEIVE PICTURE **********
  - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
  { 
  //Get image
    UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];

  //Display in ImageView object (if you want to display it
    [playerImage setImage:image];

  //Take image picker off the screen (required)
    [self dismissModalViewControllerAnimated:YES];
  }