【发布时间】:2015-07-04 18:57:51
【问题描述】:
我正在尝试通过我的 iOS 应用程序在 Facebook 上分享一些文本。 我已经设法让它在这样的 Swift 编写的应用程序中工作:
@IBAction func shareAction(sender: AnyObject) {
if SLComposeViewController.isAvailableForServiceType(SLServiceTypeFacebook){
var facebookSheet:SLComposeViewController = SLComposeViewController(forServiceType: SLServiceTypeFacebook)
facebookSheet.setInitialText("Preadded text")
self.presentViewController(facebookSheet, animated: true, completion: nil)
} else {
var alert = UIAlertController(title: "Accounts", message: "Please login to a Facebook account to share.", preferredStyle: UIAlertControllerStyle.Alert)
alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.Default, handler: nil))
self.presentViewController(alert, animated: true, completion: nil)
} }
但是,我的代码是用 Objective-C 编写的。我的问题是,在 Objective-C 中是否有类似的写法?
【问题讨论】:
标签: ios objective-c facebook share