logo
down
shadow

iOS11: UIActivityViewController not successfully sharing UIImage to 3rd party apps


iOS11: UIActivityViewController not successfully sharing UIImage to 3rd party apps

By : Gaurav Gupta
Date : November 22 2020, 03:01 PM
I hope this helps you . Short Version / TLDR
By converting your image into Data first, and then passing that object to the UIActivityViewController solves the Twitter / Facebook problem when trying to pass an image:
code :
   if let jpgImage = UIImageJPEGRepresentation(image, 0.8) {
       let vc = UIActivityViewController(activityItems: [jpgImage], applicationActivities: [])
   }
@objc func shareTapped() {
        if let image = imageView.image {
            if let jpgImage = UIImageJPEGRepresentation(image, 0.8) {
                let vc = UIActivityViewController(activityItems: [jpgImage], applicationActivities: [])
                // add the following line if using doing universal and need iPad
                vc.popoverPresentationController?.barButtonItem = navigationItem.rightBarButtonItem
                present(vc, animated: true)
            }
        }
    }


Share : facebook icon twitter icon
iOS: sharing a transparent UIImage w/ UIActivityViewController?

iOS: sharing a transparent UIImage w/ UIActivityViewController?


By : Peterx20
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further Without seeing some code it may be difficult to fully answer the question. Have you tried converting your UIImage to an NSData object using UIImagePNGRepresentation and sharing the NSdata object instead of the image itself? I would have put this in a comment rather than an answer, but I lack the rep.
Reference for UIImagePNGRepresentation: https://developer.apple.com/library/ios/documentation/uikit/reference/UIKitFunctionReference/Reference/reference.html#//apple_ref/c/func/UIImagePNGRepresentation
Sharing images/videos to other apps through UIActivityViewController shows shared items twice in iOS

Sharing images/videos to other apps through UIActivityViewController shows shared items twice in iOS


By : Eric Chabot
Date : March 29 2020, 07:55 AM
I hope this helps . UPDATE: This approach was completely wrong and will lead to unexpected results in some scenarios. Sorry if this answer mislead anyone.
The correct approach is to create one UIActivityItemProvider object for each item to be shared. And return the item to be shared from the corresponding provider object. Sorry that I couldn't update this answer before.
code :
@interface CustomItemProvider : UIActivityItemProvider
{
     NSCondition *_condition;
     NSArray *_filesToShare;
}
@end

@implementation CustomItemProvider
- (id)item
{
    _fetchInProgress = YES; 
    //Here start fetching/processing videos/photos in ANOTHER THREAD. Once the fetching/processing is complete, set the value of _fetchInProgress to NO.

    //If you want to show progress, display progress view in MAIN THREAD here.

    [_condition lock];
    while(_fetchInProgress)
    {
        [_condition wait];
    }
    [_condition unlock];

    //Here I am assuming that the files are processed and are saved to documents/cache directory and their file-paths are in _filesToShare array.

     NSMutableDictionary *itemsDict = [NSMutableDictionary dictionaryWithCapacity:[_filesToShare count]];
     for (int i = 0; i < [_filesToShare count]; i++)
     {
         NSURL *url = [NSURL fileURLWithPath:[_filesToShare objectAtIndex:i]];
         NSItemProvider *item = [[NSItemProvider alloc] initWithContentsOfURL:url];
         [itemsDict setObject:item forKey:@(i)];
     }

     return itemsDict;
}
@end
Sharing multiple files between apps using UIActivityViewController in iOS 10

Sharing multiple files between apps using UIActivityViewController in iOS 10


By : Perry Welithon
Date : March 29 2020, 07:55 AM
this one helps. There are different ways to communicate info to another app. In your case, you have decided to use application:openURL:sourceApplication:annotation:. In that case, yes, this is only for handing one object to other app. It is intended for letting the user copy a file from the current app to the other app's inbox.
UIActivityViewController display is scrolled in last iOS11 GM on iPhone7Plus

UIActivityViewController display is scrolled in last iOS11 GM on iPhone7Plus


By : Ray
Date : March 29 2020, 07:55 AM
hope this fix your issue Ok. It’s only Twitter app itself that had to be updated for iOS11 (as in iOS11, there is no longer centralized system, sharing is handled by apps such as Facebook or Twitter themselves).
UIActivityViewController crashes when sharing an UIImage I edited, but works with UIImage(named:)

UIActivityViewController crashes when sharing an UIImage I edited, but works with UIImage(named:)


By : CaptainClaw
Date : March 29 2020, 07:55 AM
may help you . I'm using the following code to combine two images into one , try to convert your new image into data first:
code :
if let imageToShare = self.combinedImage, let dataImage = UIImageJPEGRepresentation(imageToShare, 0.8) {

   let imageToShareArray = [dataImage]
   let activityViewController = UIActivityViewController(activityItems: imageToShareArray, applicationActivities: nil)
   activityViewController.popoverPresentationController?.sourceView = view

   // present the view controller
   self.present(activityViewController, animated: true, completion: nil)
}
Related Posts Related Posts :
  • How to delete specific coreData object from TableView
  • Trying to parse HTML in Swift 4 using only the Standard Library
  • Why is my minimax algorithm not undoing every move?
  • Only classes that inherit from NSObject can be declared @objc
  • Swift SQLite3 syntax and bind
  • I cant scale a Virtual Object in an other Class swift
  • Swift observer before view loaded
  • generics struct implementing protocol with associated type
  • Create new concrete object from variable
  • Adding property observer to Decodable protocol in Swift 4
  • + is unavailable: Please use explicit type conversions or Strideable methods for mixed-type arithmetics
  • Office365 GraphAPI Get Calendar Info for a specific day in Swift
  • How to assert the value of an optional Bool in Swift unit test?
  • No scientific notation and rounding with double
  • Access enum inside struct
  • Calculate time difference from Int in Swift
  • Thread 1: signal SIGABRT libc++abi.dylib: terminating with uncaught exception of type NSException (lldb)
  • xcode 9.0.1 / swift 4, No method declared with Objective-C selector 'onClick:forEvent:'
  • Swift value of Double.infinity
  • How to prevent an app crash or freeze due to a slow connection when retrieving a remote photo in Swift?
  • This dictionary where the value is a Set doesn't seem to load in Xcode
  • Creating own library that depends on RxSwift still need to import RxSwift?
  • How can I call a function that creates a button from another viewcontroller?
  • Unable to simultaneously satisfy constraints when view frame is zero
  • Swift parse csv file for result based on input
  • Increase Node Speed with SKPhysicsBody linearDamping Swift 4
  • Error handling in Swift does not involve stack unwinding. What does it mean?
  • Is it possible to use a Type as a dictionary key in Swift?
  • Time conversion from String to Date: 12 is becoming 00 swift
  • Get the Xcode project directory from the code
  • Trying to take screen grabs using iphone 7plus/8 in xcode 9 to upload to appstore but sim won't give me "100%"
  • Adding action to a button which is added to a textfield by extension in swift
  • What's the difference between using or not using the 'where' clause with generics?
  • How to remove the line under the UISearchController on iOS 11?
  • Seek one value in Array and return the second one
  • After my completion handler completes still unable to re-load tableView data swift 4
  • Specific object creation date and time
  • Xcode, No such Module
  • Xcode error Cannot parse debug map - The file was not recognized as a valid object file
  • What does let someThing = {} mean?
  • Generate random values based on a seed Swift 3
  • Should I use Delegation or DataStore to passing data BACKWARD in Clean Swift architecture?
  • Generic network call with Alamofire and ObjectMapper
  • Why does Firestore sometimes not return anything, no error, nothing?
  • How to trigger a segue from a tab bar item to another by clicking a button?
  • How to instantiate a nib into view without a viewcontroller as owner?
  • How can I pass a Post Id to a Comments VC - Swift
  • typealias is not able to use producing Cannot invoke initializer Error
  • Different values for print or console print out
  • How to create TextField for message input with 0 lines?
  • How can I make a cell and its elements look greyed out?
  • What is a viable alternative for a Dictionary for Search applications in Swift?
  • User is already logged in and save data into core data using api
  • Find an element in a stack data structure swift 4
  • Tap Gesture not working as expected when added to uiview in collectionview cell
  • "No WatchKit 1.0 app bundle found for app" Xcode 10.1 Swift 4.2
  • UISearchBar in UITableView by Rxswift
  • Cannot convert value of type '[Int]' to expected argument type 'Int'
  • Table View Height restricted Scroll
  • How to test view controller with XIB file using Quick?
  • shadow
    Privacy Policy - Terms - Contact Us © voile276.org