0

In my app there is text displayed in a label on screen.

I have a share button when pressed brings the UIActivityViewController but when you press the share extensions ex: Twitter, you get the compose view with nothing inside of it.

I want it that it puts the text from the label on the screen into the compose view.

1 Answers1

1

I don't know how you did this but it would work well. suppose you put it on a action sheet :

let share = UIAlertAction(title: "Share my label!", style: .Default, handler: { action in
        let shareMessage = myLabel.text
        let itemsToShare = [shareMessage]

        let activityViewController = UIActivityViewController(activityItems: itemsToShare,
            applicationActivities: nil)

        self.presentViewController(activityViewController, animated: true, completion: nil)

    })
sbsr
  • 352
  • 3
  • 9
  • I asked for share extenion @SaeidBsn – Nikhil C Kanamarla Aug 22 '15 at 21:16
  • You asked for a share extension but the description of what the rest of your question asked for sounds like `UIActivityViewController`. A share extension allows you to add a new item related to your app in the share menu of other apps. Perhaps you could add some code to your question showing what you have tried. – Paulw11 Aug 22 '15 at 21:45
  • @NikhilCKanamarla you can refer to this link for full sample http://www.appcoda.com/ios8-share-extension-swift/ – sbsr Aug 24 '15 at 14:45