UIActivityViewController strips out extra spaces I put in for formatting purposes

27 Views Asked by At

I am trying to share formatted text which has extra spaces using UIActivityViewController.

So if I share "Estimate: $400" via email, the received email has the text: "Estimate: $400", without the extra spaces.

Is there a way to allow multiple spaces between words ?

   @IBAction func shareTextButton(_ sender: UIButton) {
        
        //Formatted text to share
        let text = "Estimate:       $400"
        
        // set up activity view controller
        let textToShare = [ text ]
        let activityViewController = UIActivityViewController(activityItems: textToShare, applicationActivities: nil)
        
        // present the view controller
        self.present(activityViewController, animated: true, completion: nil)
    }
1

There are 1 best solutions below

0
HangarRash On

Use non-breaking spaces instead of regular spaces. You can easily type non-breaking spaces using Option-space (⌥-space).