8

我正在使用 UIActivityViewController 在 ios 6 和我的代码上共享图像

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

一切正常,但无法将 shareImage 粘贴到 iMessage。我不知道为什么?感谢您的帮助!

4

1 回答 1

1

正如其他人所说,iMessage 只支持文本,不支持图像。虽然这听起来像在 iOS7 中,但它确实有效。

我个人知道我已经让它与 OvershareKit 一起工作:https ://github.com/overshare/overshare-kit 。

它当然会增加一些开销,但允许您使用其流畅的界面/API 与几乎所有媒体共享。

于 2013-12-30T02:40:14.563 回答