iOS8中的“共享”选项遇到了一些问题。
使用以下代码,我可以通过电子邮件和短信(SMS)正确分享,包括我的文本字符串和我的图像。 但是当我尝试分享到Facebook时,生成的帖子只包含我的图像(跳过文本字符串),而如果我尝试在WhatsApp上分享,则跳过图像并且只传递文本字符串。
有人有任何建议吗?
我的代码:
@IBAction func shareButtonClicked(sender: UIBarButtonItem) {
var kidToShare1 : String? = noKids
if selectedKid == nil {
kidToShare1 = noKids
println("kid is nil")
} else {
kidToShare1 = selectedKid!.kidName
}
let kidToShare = NSLocalizedString("Kid: ", comment:"Kid to share") + kidToShare1!
let imageToShare = photo! ?? noPhoto!
let textToShare = NSLocalizedString("Event Description: ", comment:"Text to share") + descriptionText as NSString
let dateToShare = NSLocalizedString("Event Date: ", comment: "Date to share") + formatDate(date) as NSString
let message = NSLocalizedString("My App", comment: "Main sharing message")
let objectsToShare = [message, dateToShare, kidToShare, textToShare, imageToShare]
let activityVC = UIActivityViewController(activityItems: objectsToShare, applicationActivities: nil)
activityVC.excludedActivityTypes = [UIActivityTypeAirDrop, UIActivityTypeAirDrop, UIActivityTypeAssignToContact, UIActivityTypeAddToReadingList,UIActivityTypeCopyToPasteboard,UIActivityTypeSaveToCameraRoll,UIActivityTypePrint]
self.presentViewController(activityVC, animated: true, completion: nil)
}
}