[英]IOS: how to show completion result of social framework
我试图迅速在IOS中为Facebook使用社交框架。 我尝试了以下代码,但是无法显示警报窗口...
if SLComposeViewController.isAvailableForServiceType(SLServiceTypeFacebook){
var mes: String = ""
let shareWindow: SLComposeViewController = SLComposeViewController(forServiceType: SLServiceTypeFacebook)
//configure initial text
shareWindow.setInitialText("XXX")
self.presentViewController(shareWindow, animated: true, completion: nil)
//handle the result of this share
shareWindow.completionHandler = { result -> Void in
let getResult = result as SLComposeViewControllerResult;
switch(getResult.rawValue) {
case SLComposeViewControllerResult.Cancelled.rawValue:
mes = "Cancelled!"
case SLComposeViewControllerResult.Done.rawValue:
mes = "Successfully Posted!"
default:
mes = ""
}
self.dismissViewControllerAnimated(true, completion: nil)
}
if mes.isEmpty == false {
let alertView = UIAlertController(title: "Facebook Post Result", message: mes, preferredStyle: .Alert)
alertView.addAction(UIAlertAction(title: "Ok", style: .Default, handler: nil))
presentViewController(alertView, animated: true, completion: nil)
}
}
有人可以给我一个提示吗? 非常感谢!
尝试在完成处理程序结束之后和IF之前移动self.presentViewController(shareWindow, animated: true, completion: nil)
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.