是否可以通过UIActivityViewController与Linkedin共享文本链接?

时间:2014-10-22 20:11:41

标签: swift linkedin uiactivityviewcontroller

我想通过UIActivityViewController与Linkedin共享链接+文本,但我的代码不起作用:(我看到Facebook和Twitter但不是Linkedin

    let url: NSURL =  NSURL(string: "http://www.google.com")!
    let text: String = "Test Linkedin"

    let items: [AnyObject] = [url, text]

    let activityViewController: UIActivityViewController = UIActivityViewController(activityItems: items, applicationActivities: nil)
    activityViewController.setValue("Test", forKey: "subject")
    self.presentViewController(activityViewController, animated: true, completion: nil)

如果我只设置了网址,我会在选项中看到Linkedin。问题出在哪儿?我看到Safari Sharing运行良好。

1 个答案:

答案 0 :(得分:0)

Apple不为LinkedIn提供活动。如果要与UIActivityViewController共享文本和链接,则需要创建自己的UIActivity。请参阅此处的文档:

https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIActivity_Class/index.html

您还可以查看此SO帖子,它将向您展示如何创建自定义的帖子(在Objective-C中)

How can I create a custom UIActivity in iOS?