iOS:如何在社交网络上共享文字和图像? [英] iOS: How to share text and image on social networks?

查看:168
本文介绍了iOS:如何在社交网络上共享文字和图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  NSString * sharedMsg = [NSString stringWithFormat:@你好,世界]; 
UIImage * sharedImg = [UIImage imageNamed:@image];
NSArray * sharedObjects = [NSArray arrayWithObjects:sharedMsg,sharedImg,nil];
UIActivityViewController * activityViewController = [[UIActivityViewController alloc]
initWithActivityItems:sharedObjects applicationActivities:nil];
activityViewController.popoverPresentationController.sourceView = self.view;
[self presentViewController:activityViewController animated:YES completion:nil];

在运行时,当我选择Facebook的图标时,文字丢失,图像正确显示。 br>
我的xcode是6.3.1,在iPad上测试。

解决方案

似乎最近更新了Facebook应用程序已经取代了内置的Facebook共享活动,忽略了状态文本 - 如果从设备中删除Facebook应用程序,文本将使用您的代码显示。如果您安装了Facebook应用程序,您将获得图像,URL但不是文本



Facebook的政策不允许您预先填充状态消息,并要求所有内容为用户生成 - 虽然我明白这个背后的意图,我个人认为在许多情况下这是一种愚蠢 - 例如在我的游戏中,我想预先填充用户的分数,但是现在我不能,所以用户被呈现一个空的对话框。我可能会简单地删除Facebook共享选项,因为现在没有人会使用它。



来自Facebook的回复确认行为是由设计


Please, can you tell me if I'm doing mistakes?

NSString *sharedMsg=[NSString stringWithFormat:@"Hello world"];
UIImage* sharedImg=[UIImage imageNamed:@"image"];
NSArray* sharedObjects=[NSArray arrayWithObjects:sharedMsg, sharedImg, nil];
UIActivityViewController *activityViewController = [[UIActivityViewController alloc] 
              initWithActivityItems:sharedObjects applicationActivities:nil];
activityViewController.popoverPresentationController.sourceView = self.view;
[self presentViewController:activityViewController animated:YES completion:nil];

At runtime when I select the icon of Facebook the text is missing, the image is correctly displayed.
My xcode is 6.3.1, tested on iPad.

解决方案

It seems that a recent update to the Facebook application has replaced the in-built Facebook share activity with one that ignores status text - If you remove the Facebook app from your device the text will be displayed using the code you have. If you have the Facebook app installed you get images, URLs but not the text

Facebook's policies don't allow you to pre-populate status messages and require all content to be user generated - while I understand the intention behind this, I personally think it is kind of stupid in many cases - For example in my game I want to pre-populate the user's score, but now I can't, so the user is presented with an empty dialog box. I will probably simply remove the Facebook sharing option as no-one will ever use it now.

This response from Facebook confirms that the behaviour is by design

这篇关于iOS:如何在社交网络上共享文字和图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆