but when i choose to share via facebook, messenger or whatsapp it only gives text (image is not shared). Update note: Owen L Brown updated this tutorial for Xcode 10.1, Swift 4.2, and iOS 12. I am trying to share both image and text in swift. With that, you now init UIActivityViewController with your view controller. In this UIActivityViewController tutorial, you’ll learn all about giving your users the ability to export their data and share it with others. So, if the user taps on that operation, the app will crash. You could even return different types (String/UIImage/etc).įunc activityViewControllerPlaceholderItem ( activityViewController : UIActivityViewController ) -> AnyObject let items profileImageView.image let ac UIActivityViewController(activityItems: items, applicationActivities: nil) present(ac, animated: true) When you share an image from your app, users can save it in the gallery, but writing to the photo library is a restricted operation. NSData someData /./ UIActivityViewController activityViewController UIActivityViewController alloc initWithActivityItems: someData applicationActivities:nil But unfortunately this resulted in something like this: So in order to get a filename instead of Attachment-1 I create a file in the temporary directory and pass. The better, more advanced way, is to implement UIActivityItemSource for your view controller.īy implementing the protocol, you can change the string to returning, depending on what activity it is.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |