我刚刚为共享助手创建了一个包装类,我的代码如下。
let activityVC = UIActivityViewController(activityItems: [message], applicationActivities: nil)
activityVC.setValue(subject, forKey: "subject")
activityVC.completionWithItemsHandler = {(activityType: String!, completed:Bool, objects:[AnyObject]!, error:NSError!) in
}
fromVC.presentViewController(activityVC, animated: true, completion: nil)
问题从这里开始,UIActivityItemSource方法没有被调用
override func activityViewController(activityViewController: UIActivityViewController, itemForActivityType activityType: String) -> AnyObject? {
switch activityType
{
case UIActivityTypeMail:
return msg
case UIActivityTypeMessage:
return msg
case UIActivityTypePostToFacebook:
return msg
case UIActivityTypePostToTwitter:
return strTwitterShare
default:
return msg
}
}
感谢您的帮助
答案 0 :(得分:3)
如果你使用let activityVC = UIActivityViewController(activityItems:[self],applicationActivities:nil)
...然后在itemForActivityType方法中提供您的消息。