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