2

I am trying to send view containing an image with text and converted to image by using this code

- (UIImage *)imageWithView3:(UIView *)view
{
    CGSize imageSize = viewAll.bounds.size;

    UIGraphicsBeginImageContextWithOptions(imageSize, viewAll.opaque, 0.0);

    [view.layer renderInContext:UIGraphicsGetCurrentContext()];

    UIImage * img = UIGraphicsGetImageFromCurrentImageContext();

    UIGraphicsEndImageContext();

    return img;
}

and I then attempt to send the image view via iMessage using this code

if ([MFMessageComposeViewController canSendText] && [MFMessageComposeViewController canSendAttachments] && [MFMessageComposeViewController isSupportedAttachmentUTI:(NSString *)kUTTypePNG]) {

    MFMessageComposeViewController *vc = [[MFMessageComposeViewController alloc] init];
    vc.messageComposeDelegate = self;
    UIImage *myImage = [self imageWithView3:self.viewAll];
    BOOL attached = [vc addAttachmentData:UIImagePNGRepresentation(myImage) typeIdentifier:(NSString*)kUTTypePNG filename:@"image.png"];

    if (attached) {

        NSLog(@"Attached (:");
    }
    else {

        NSLog(@"Not attached ):");
    }

    [self presentViewController:vc animated:YES completion:nil];
}

but it's not working; can anybody tell me what's the wrong on this code

BergQuester
  • 6,167
  • 27
  • 39
Sonic
  • 518
  • 1
  • 7
  • 19
  • 4
    What does it mean it’s not working? When you run the code, a chimpanzee jumps in through the window and steals your computer? Or is there an error message? – zoul Aug 09 '14 at 18:35
  • no; it's jump to message window but without image attach; and please this is not a joke; if you can help ok; otherwise if you keep silent you helped also; so try to help persons at first and this site for helping others – Sonic Aug 09 '14 at 23:00
  • 1
    Have you found an answer to your question yet? – Gasper Sep 21 '14 at 22:04

0 Answers0