是否有人可以提供一些见解,正在徘徊。对于我的生活,我无法弄清楚如何发送带有 UIActivityTypeMessage 的 UIImage,尽管有人说这是可能的。
UIActivityTypeMessage
该对象将提供的内容发布到消息应用程序。使用此服务时,您可以提供 NSString 和 NSAttributedString 对象作为事件项的数据。您还可以指定其内容使用短信方案的 NSURL 对象。 适用于 iOS 6.0 及更高版本。 在 UIActivity.h 中声明。
据我所知,我只能发送 NSString/NSURL。我没看到你这是可能的。
我正在使用这个:
UIImage *image; // some image here.
UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:@[ image ] applicationActivities:nil];
如有任何帮助,我们将不胜感激。
最佳答案
以下是如何普遍使用 UIActivityViewController,包括文本和图像。
NSMutableArray *items = [NSMutableArray new];
[items addObject:@"Hello world!"];
[items addObject:[UIImage imageNamed:@"MyImage"]];
NSArray *activityItems = [NSArray arrayWithArray:items];
UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:nil];
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
[self presentViewController:activityViewController animated:YES completion:nil];
} else if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
UIPopoverController *aPopoverController = [[UIPopoverController alloc] initWithContentViewController:activityViewController];
[aPopoverController presentPopoverFromBarButtonItem:self.actionButton permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}
// Examples:
// iPhone:
// http://anglerally.com/wp-content/uploads/2012/09/6-Default-568h@2x.png
// http://anglerally.com/wp-content/uploads/2012/09/7-Default-568h@2x.png
// iPad:
// http://anglerally.com/wp-content/uploads/2012/09/6-Default-Portrait@2xipad.png
// http://anglerally.com/wp-content/uploads/2012/09/7-Default-Portrait@2xipad.png
关于objective-c - 用 UIImage 组合 UIActivityTypeMessage,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12593255/