iOS6のネイティブメッセージコンポーザーに画像を添付するには? デフォルトの写真アプリで見られるメッセージ機能を介して同じ共有を実装したいと思います。
ありがとう
iOS6のネイティブメッセージコンポーザーに画像を添付するには? デフォルトの写真アプリで見られるメッセージ機能を介して同じ共有を実装したいと思います。
ありがとう
{
NSMutableDictionary * attachment = [[NSMutableDictionary alloc]init];
[attachment setObject: UIImageJPEGRepresentation(imageView.image,0.5) forKey:@"attachmentData"];
[attachment setObject: @"productImage.jpeg" forKey:@"attachmentFileName"];
[attachment setObject: @"jpeg" forKey:@"attachmentFileMimeType"];
NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
[params setObject: @"subject" forKey:@"subject"];
[params setObject: @"matterText" forKey:@"matterText"];
[params setObject: [[NSMutableArray alloc]initWithObjects:attachment, nil] forKey:@"attachments"];
}
#pragma mark - Sharing Via Email Related Methods
-(void)emailInfo:(NSMutableDictionary*)info
{
if (![MFMailComposeViewController canSendMail])
{
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:@"Email Configuration"
message:@"We cannot send an email right now because your device's email account is not configured. Please configure an email account from your device's Settings, and try again."
delegate:nil
cancelButtonTitle:nil otherButtonTitles:@"OK", nil];
[alert show];
return;
}
MFMailComposeViewController *emailer = [[MFMailComposeViewController alloc] init];
emailer.mailComposeDelegate = self;
NSString * subject = [info objectForKey:@"subject"];
NSString * matterText = [info objectForKey:@"matterText"];
if(subject)
[emailer setSubject:subject];
if(matterText)
[emailer setMessageBody:matterText isHTML:NO];
NSMutableArray * attachments = [info objectForKey:@"attachments"];
if (attachments)
{
for (int i = 0 ; i < attachments.count ; i++)
{
NSMutableDictionary * attachment = [attachments objectAtIndex:i];
NSData * attachmentData = [attachment objectForKey:@"attachmentData"];
NSString * attachmentFileName = [attachment objectForKey:@"attachmentFileName"];
NSString * attachmentFileMimeType = [attachment objectForKey:@"attachmentFileMimeType"];
[emailer addAttachmentData:attachmentData mimeType:attachmentFileMimeType fileName:attachmentFileName];
}
}
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
emailer.modalPresentationStyle = UIModalPresentationPageSheet;
}
[self.navigationController.topViewController presentViewController:emailer animated:YES completion:nil];
}
メッセージコンポーザーに画像を添付できないと思います。メールコンポーザーでのみ可能です。