2015-09-02 62 views
2

我只是做了一個包裝類的共享助手我的代碼如下。itemForActivityType不被調用

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 
      } 

     } 

感謝您的幫助

回答

2

如果使用讓activityVC = UIActivityViewController(activityItems它應該工作:[個體經營],applicationActivities:無)

...那麼你的消息是在你的itemForActivityType方法中提供的。