2 garaster garaster 于 2013.08.12 16:07 提问

定制UIActivityViewController

要在UIActivityViewController 邮件中添加一个屏幕截图附件,屏幕截图不需要存在数据库中。

代码:

-(IBAction)ActivityController:(id)sender {{
    NSString *shareString = @"";
    UIImage *shareImage = [UIImage imageNamed:@""];
    NSURL *shareUrl = [NSURL URLWithString:@""];
    NSArray *activityItems = [NSArray arrayWithObjects:shareString,shareImage, shareUrl, nil];
    UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:nil];
    activityViewController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
    [self presentViewController:activityViewController animated:YES completion:nil];

    MFMailComposeViewController *mailController = [[MFMailComposeViewController alloc] init];

    mailController.mailComposeDelegate = self;
    UIGraphicsBeginImageContext(self.view.bounds.size);
    [self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    NSData *exportData = UIImageJPEGRepresentation(image ,1.0);
    [mailController addAttachmentData:exportData mimeType:@"image/jpeg" fileName:@"Screenshot.jpeg"];

但是邮件中的附件没添加成功。

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!