8

I'm using UIActivityViewController to share image on ios 6 and my code

        UIImage *shareImage = [UIImage imageNamed:@"myImage.png"];

        // Init array
        NSMutableArray *items = [NSMutableArray new];
        [items addObject:@""];
        [items addObject:shareImage];

        // Add image to paste board
        UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
        pasteboard.persistent = YES;
        pasteboard.image = shareImage;

        UIActivityViewController *activityVC = [[UIActivityViewController alloc]initWithActivityItems:items applicationActivities:nil];

        //This is an array of excluded activities to appear on the UIActivityViewController
        activityVC.excludedActivityTypes = @[UIActivityTypePostToWeibo,
                                             UIActivityTypePrint,
                                             UIActivityTypeCopyToPasteboard,
                                             UIActivityTypeAssignToContact,
                                             UIActivityTypeSaveToCameraRoll];

        [self presentViewController:activityVC animated:TRUE completion:nil];

Everything working fine but cannot paste shareImage to iMessage. I don't know why? Thank for your help!

Nithin Michael
  • 2,166
  • 11
  • 32
  • 56
crz
  • 438
  • 5
  • 18
  • I don't think you can: http://stackoverflow.com/questions/12593255/compose-uiactivitytypemessage-with-uiimage – Jai Govindani Mar 27 '13 at 12:29
  • 1
    Text only with action sheet. You can share the image with mail and other options such twitter Facebook and so on but in iMessage it only allows text. You can look up cocoa controls one of those may have a costum class for that but as far as action sheet is conserned no luck man. – Adrian P Mar 27 '13 at 23:40
  • check my Answer : http://stackoverflow.com/questions/15758163/how-can-i-attach-image-to-uiactivityviewcontroller-message-ios/15758309#15758309 – Bhavin Apr 02 '13 at 07:20
  • @Vin: it's not working – crz Apr 03 '13 at 04:35
  • 1
    @crz I'm using similar code to yours and I can confirm that the image now posts fine to iMessage in iOS7 – Tim May 30 '14 at 01:40

1 Answers1

1

As others have said, iMessage only supports text, not images. Although it sounds like in iOS7, it does work.

I know personally I've gotten it to work with OvershareKit: https://github.com/overshare/overshare-kit .

It of course adds a bit of overhead but allows you to share with just about every medium there is with their slick interface/APIs.

valheru
  • 2,552
  • 3
  • 20
  • 40