UIActivityViewController只共享文本 [英] UIActivityViewController share only text

查看:252
本文介绍了UIActivityViewController只共享文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用UIActivityViewController分享只是简单的文本
我使用swift,与xcode 6.3
代码非常简单,适用于照片,但不只是文本,
我不想包含任何具有objectsToShare的网址,只需干净的文本
这里是代码:

  var objectsToShare :[一些文字要分享]! 
let activityVC = UIActivityViewController(activityItems:objectsToShare,applicationActivities:nil)

//已完成任务的处理程序
activityVC.completionHandler = {(activityType,completed:Bool)in
if!completed {
println(cancelled)
return
}
reportCompleted()//向服务器报告完成。
}

//排除的活动代码
activityVC.excludedActivityTypes = [UIActivityTypeAirDrop,UIActivityTypeAddToReadingList,UIActivityTypeCopyToPasteboard]

//激活共享视图
self.presentViewController(activityVC,animated:true,completion:{
(complete)in
println(complete)

})

现在我知道这完全取决于用户拥有的Facebook - 不仅在他的手机上,还在于他的设置。
(我直接从我的手机6,它的Facebook设置,而不是从模拟器)
这个代码一直工作正常,仍然工作良好的图像,而不是文本,但从某种原因,它停止工作的文本共享,也许文本本身有关系,也许我的代码不好,或者也许Facebook,改变一些。



谢谢关于这个问题的任何想法。



为了使事情变得更奇怪,我发现了更多奇怪的事情。


  1. 发布文本的代码正在模拟器上工作(只要您在设置页面中添加)

  2. 如果我添加到网址,它也可以工作(在设备中)如果我删除网址不起作用。

//代码工作:

  var myWebsite = NSURL(string:http://www.someurl.com/)

let textToShare =Swift is awesome看看这个网站吧!

objectsToShare = [textToShare,myWebsite!]
//继续正常。

//无效的代码:

  let textToShare =Swift真棒!看看这个网站吧! 

objectsToShare = [textToShare]


解决方案

p>似乎它不是一个错误,但Facebook政策更新:



在与我们的团队讨论剥离文本的预填充消息区域之后,这是实际上BY DESIGN与新的共享扩展
预填文本违反平台策略2.3 .....所以在所有执行策略2.3是一个功能,而不是一个bug。
https://developers.facebook.com/bugs/949486035103197/


I want to share just simple text using UIActivityViewController I am using swift, with xcode 6.3 The code is very simple, work great for photos, but not just text, I don't want to include any web URL with the objectsToShare, just clean text Here is the code:

var objectsToShare: ["some text to share"]! 
let activityVC = UIActivityViewController(activityItems: objectsToShare, applicationActivities: nil)

//handler for completed task
activityVC.completionHandler = {(activityType, completed:Bool) in
            if !completed {
                println("cancelled")
                return
            }
reportCompleted() //report to server it's done.
 }

//Excluded Activities Code
activityVC.excludedActivityTypes = [UIActivityTypeAirDrop, UIActivityTypeAddToReadingList, UIActivityTypeCopyToPasteboard ]

//activate the share view
self.presentViewController(activityVC, animated: true,  completion: {
            (complete)  in
            println(complete)

        })

Now I know that it's all depends on the user have Facebook - not only on his phone, but also on his setting. (I tried that directly from my phone 6, which has Facebook setting, and not from the simulator) This code once worked fine, and still working good for images, and not text, but from some reason, it stop working for text sharing, Maybe the text itself has something to do with, maybe my code is not good, or maybe Facebook, change something.

Thank you for any thought about the subject.

To make thing more strange I found 2 more strange things.

  1. The code of publish text is working on a simulator (as long as you add in the setting facebook)
  2. If I add to the web url it also work (in device) if I remove the web url it is not working.

//code that work:

var myWebsite = NSURL(string: "http://www.someurl.com/")

    let textToShare = "Swift is awesome!  Check out this website about it!"

     objectsToShare = [textToShare , myWebsite!]
//continue regular.

//code that doesn't work:

    let textToShare = "Swift is awesome!  Check out this website about it!"

     objectsToShare = [textToShare ]

解决方案

It seems that it is not a bug but facebook policy update:

"After discussing this with our team regarding stripping the pre-filling message area of text, this is actually BY DESIGN with the new share extension. Pre-filling texts violates Platform Policy 2.3 ..... So in all enforcing policy 2.3 is a feature and not a bug. " https://developers.facebook.com/bugs/949486035103197/

这篇关于UIActivityViewController只共享文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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