Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/110.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/opengl/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 如何使用MFMailComposeViewController发送图像_Ios_Uiimageview_Mfmailcomposeviewcontroller - Fatal编程技术网

Ios 如何使用MFMailComposeViewController发送图像

Ios 如何使用MFMailComposeViewController发送图像,ios,uiimageview,mfmailcomposeviewcontroller,Ios,Uiimageview,Mfmailcomposeviewcontroller,我正在尝试使用MFMailComposeViewController发送电子邮件,但不知何故它无法工作。当我不发送图像时,一切正常。但如果我尝试添加照片,则会出现以下错误: -(IBAction)gonder:(id)sender{ MFMailComposeViewController *mailComposeViewController = [[MFMailComposeViewController alloc] init]; mailComposeViewController.ma

我正在尝试使用MFMailComposeViewController发送电子邮件,但不知何故它无法工作。当我不发送图像时,一切正常。但如果我尝试添加照片,则会出现以下错误:

-(IBAction)gonder:(id)sender{
  MFMailComposeViewController *mailComposeViewController = [[MFMailComposeViewController alloc] init];
  mailComposeViewController.mailComposeDelegate = self;

  [mailComposeViewController setSubject:@"deneme"];
  UIImage *savedImage = self.image;
  NSData *imageData = UIImagePNGRepresentation(savedImage);
  [mailComposeViewController addAttachmentData:imageData mimeType:@"image/png" fileName:@"photo"];
  NSString *emailBody = @"my text";
  [mailComposeViewController setMessageBody:emailBody isHTML:NO];

  [emailBody release];
  NSArray *alicilar=[[NSArray alloc]initWithObjects:@"mymailadress.com", nil];
  [mailComposeViewController setToRecipients:alicilar];

  [mailComposeViewController view];
}

- (void) mailComposeController:(MFMailComposeViewController*)mailComposeViewController bodyFinishedLoadingWithResult:(NSInteger)result error:(NSError*)error
{
  @try
  {
    id mailComposeController = [mailComposeViewController valueForKeyPath:@"internal.mailComposeController"];
    id sendButtonItem = [mailComposeViewController valueForKeyPath:@"internal.mailComposeView.sendButtonItem"];
    [mailComposeController performSelector:@selector(send:) withObject:sendButtonItem];
  }
  @catch (NSException *e) {}
  [mailComposeViewController release];
}
这些是错误:

2012-02-14 16:19:58.322 il[653:307]***错误:FigCreateCImageFromJPEG返回-12905。输入(null)为444585字节。

您试图附加的图像是否很大?这可能是内存不足的问题。

我认为问题在于创建数据对象的方式。试试这个:

NSData *imageData = [NSData dataWithData:UIImagePNGRepresentation(savedImage)];

也可以考虑使用JPEG代替PNG,这有点快。

我用我的手机摄像头捕捉图像。我正在尝试连接它。如何最小化此图像?