I have a document's directory path of a gif I'd like to post to Facebook, but unfortunately when I use this process, it posts a static image instead of it being animated. I know it's animated because I can save the same image to my camera roll and see that it animates. Is there anyway of posting an animated version of this GIF?
let image = UIImage(contentsOfFile: path) // document directory path
let sharePhoto = FBSDKSharePhoto()
sharePhoto.image = image
let content = FBSDKSharePhotoContent()
content.photos = [sharePhoto]
let shareDialog: FBSDKShareDialog = FBSDKShareDialog()
shareDialog.shareContent = content
shareDialog.mode = .native
shareDialog.show()
This is not as issue with your image due to Facebook natively not support gif image directly uploaded on it.
You can share gif image link on Facebook and it will show there gif image. Like as commonly peoples are using giphy, tenor website and share gif image link from this website. So gif image display via this type of website.
I hope this will help you.
Related
I'm trying to share a photo to Messanger but it fails without returning any error.
But if I create a link instead of photo it works successfully.
photo.image = image
photo.isUserGenerated = true
let content = FBSDKSharePhotoContent()
content.photos = [photo]
FBSDKMessageDialog.show(with: content, delegate: nil)
I'm loading images from the photo library via UIImagePickerController and with that image I'm setting the material of a SCNPlane:
let imageView = UIImageView(image: image)
imageView.contentMode = .scaleAspectFit
plane.firstMaterial?.diffuse.contents = imageView
With some images, this works fine, no problem at all, the image shows up properly. However, with other images, the texture of the plane shows up as entirely black and Xcode prints "Unsupported IOSurface format: 0x00000000". It seems to be only images that were screenshots causing this, although some screenshot images work just fine.
SceneKit can display both PNGs and JPGs, some PNGs just seem to cause issues. Not sure why or whether it's a bug or not. What you can do that's probably better than converting everything to JPGs (so you can retain transparency) is set your material contents to the image's CGImage:
if let cgImage = image.cgImage {
geometry.firstMaterial?.diffuse.contents = cgImage
}
You can also convert your image to a JPEG via something like this, as SceneKit doesn't seem to have issues with JPGs:
if let jpegData = image.jpegData(compressionQuality: 1.0) {
image = UIImage(data: jpegData)!
}
You will lose transparency doing it this way however.
I have configured my Provider Configuration for CallKit iOS. In which I have also set 'iconTemplateImageData' for displaying app icon in CallKit UI. But app icon is not showing. It shows a white square box.
Provider Configuration Code:
CXProviderConfiguration *configuration = [[CXProviderConfiguration alloc] initWithLocalizedName:[NSString stringWithFormat:#"%#\n", _title]];
configuration.maximumCallGroups = 1;
configuration.maximumCallsPerCallGroup = 1;
UIImage *callkitIcon = [UIImage imageNamed:#"AppIcon"];
configuration.iconTemplateImageData = UIImagePNGRepresentation(callkitIcon);
_callKitProvider = [[CXProvider alloc] initWithConfiguration:configuration];
[_callKitProvider setDelegate:self queue:nil];
_callKitCallController = [[CXCallController alloc] initWithQueue:dispatch_get_main_queue()];
I have used AppIcon images in 'Images.xcassets' with sizes: -
1x: 40*40, 2x: 80*80, 3x: 120*120
Please help why my app icon is not showing.
Thanks in advance.
This is likely because you are using your AppIcon image, which is a fully opaque image, i.e. no part of that image is transparent or has alpha=0.
To get the desired effect, you have to use a different image which is partly (or mostly) transparent. The native in-call UI will only use the alpha channel of the image you provide, so it ignores colors. I suggest following the example in the Speakerbox sample app and providing a secondary PNG image in your image asset catalog with transparency.
You need to use below code in order to set app name and app icon for incoming VOIP calls
let localizedName = NSLocalizedString("App-Name", comment: "Name of application")
let providerConfiguration = CXProviderConfiguration(localizedName: localizedName)
providerConfiguration.iconTemplateImageData = UIImage.init(named: "appicon-Name")?.pngData()
Note: Your app icon must be transparent. result will be like in below image
I have a working code where I copy an image to UIPasteboard, but I cannot find a way to implement the PASTE functionality programmatically. Any idea or tip?
The following piece of code might work. Make sure you are testing on the device.
let image = UIImage(named: "person.png")
UIPasteboard.generalPasteboard().image = image;
based on the comment, you can do it as follows. I am putting here the objective-c code, I hope you could get the idea then convert it to the swift.
NSData* pasteData = [[UIPasteboard generalPasteboard] dataForPasteboardType:(NSString*)kUTTypeJPEG];
you may find the swift solution in the following url
Swift UIPasteboard not copying PNG
Swift 3
If an imaged has been copied from another application (e.g. Safari) this is how I add it into my app. I trigger this from a UIAlertController as a UIAlertAction.
let pasteboard = UIPasteboard.general
if pasteboard.hasImages {
myImage.image = pasteboard.image
}
Alternatively, you may use NSData. It works on Simulator too.
// Copy
let image = UIImage(named: "sample")
let imageData = UIImageJPEGRepresentation(image!, 1)
UIPasteboard.general.setData(imageData!, forPasteboardType: "image")
// Paste
let imageData = UIPasteboard.general.data(forPasteboardType: "image")
let image = UIImage(data:imageData!)
copiedImage.image = image
I'm sure this is a simple question, but I'm still pretty new to Swift, so I can't figure it out. Basically, I have followed this tutorial to implement a custom loading animation. It's working fine in my app with the demo image, however I can't figure out how to add a URL from a different class.
I need to be able to set the url of the image in viewDidAppear and this is also when I would like the animation to start.
Can anyone help me out?
You need to create an NSURL for the URL of the image you want to get.
Then create an instance of NSData with contentsOfUrl to get the URL as data.
Then create a UIImage with the NSData
Then update the imageView with the new image
let myPhotoUrl = NSURL(string: "http://myfancypics.com/abc.jpg")
let photoDataFromUrl = NSData(contentsOfURL: myPhotoUrl!)
let myImage = UIImage(data: photoDataFromUrl)
imageView.image = myImage