2017-05-29 77 views
0

image份額從文本

時,我想分享在Twitter上 文本有更多的則是文本,以便我能做些什麼,分享陣風文本。 這個代碼

 @IBAction func shareButton(_ sender: Any) { 

      UIPasteboard.general.string = "\(titleLabel)" 
      if SLComposeViewController.isAvailable(forServiceType: SLServiceTypeTwitter){ 
       let twitterSheet:SLComposeViewController = SLComposeViewController(forServiceType: SLServiceTypeTwitter) 
       twitterSheet.setInitialText ("\(titleLabel) \n ") 
       self.present(twitterSheet, animated: true, completion: nil) 
      } else { 
       let alert = UIAlertController(title: "حساب", message: "الرجاء تحميل برنامج تويتر.", preferredStyle: UIAlertControllerStyle.alert) 
       alert.addAction(UIAlertAction(title: "موافق", style: UIAlertActionStyle.default, handler: nil)) 
       self.present(alert, animated: true, completion: nil) 
      } 

謝謝大家

回答

-1

僅使用文本

twitterSheet.setInitialText ("\(titleLabel.text!) \n") 
+0

謝謝。但現在是這樣。可選(「文本」).我如何刪除可選項和(「」)再次感謝您。 @apineda – hamid

+0

把「!」文本屬性(更新後的答案)後。 – apineda

+0

謝謝你的工作 – hamid