2

iOS6のネイティブメッセージコンポーザーに画像を添付するには? デフォルトの写真アプリで見られるメッセージ機能を介して同じ共有を実装したいと思います。

ありがとう

4

3 に答える 3

1
{
  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];

}
于 2013-05-28T06:15:39.883 に答える
0

メッセージコンポーザーに画像を添付できないと思います。メールコンポーザーでのみ可能です。

于 2013-05-28T06:42:02.050 に答える