My problem is that I want to show a gif in the UIImageView while downloading a picture from remote server. After I downloaded the picture from remote server, I want this downloaded picture to be shown on the screen.
Without problem, I achieved showing the downloaded picture on the screen, which is not difficult of course. However, I could not achieve displaying a custom preinstalled gif in my local while trying to download that picture. Default ActivityIndicator icon appears while downloading.
I did try a few things but I still could not make it. Is there any suggestion for that ?
I put some pictures:
Before I began to download: UImageView with white background color
After I started to download image for UImageView: default activity indicator
Downloaded image: Which I wanted so.
I just want to replace second picture: Activity indicator with my gif. I hope I am understood.
You cannot play a gif format file in a UIImageView. If you have an array of images, you can ainmate them in the imageView and it will be just like a gif.You can also repeat the animation if you want to.
You need to add UIImage+animatedGIF category to support gif in imageView.
If you want to play gifs from the url, you can consider the webView instead of imageView.
There is no built-in support for animated GIFs in iOS. I found a third-party framework that lets you display animated GIFs. I'm not at my Mac right now so I don't have the info, but it looks like there are quite a few libraries that offer animated GIF support on Github.
As Mr. T. says you can also use an array of images in UIImageView to get the same effect. (And there are tools that let you decompose an animated GIF into its frames.)
Related
In the app I have a UICollectionView with item size so that about ~20 items are visible on the screen at the same time. The content that I want to display in each cell is Gif image downloaded from Giphy / Tenor.
However, I realized that gif files take much more space (and time to load) than the relative mp4 files that both Tenor and Giphy provide for each animated image, which is actually obvious, cause mp4 file format has a compressing logic and stuff like that. Sorry if I use wrong terms.
In order to have list loaded faster I decided to switch using UIImageView with GIF images to AVPlayerLayer, cause mp4 file is like ~10x lighter than GIF image. But I faced with the performance issue similar to what described HERE. The flow is mostly the same, I have 20+ items visible at the same time, but because of hardware limitations it only shows 16 videos. I couldn't find any workaround or any other frameworks that would allow to have more than 16 AVPlayerLayer showing video at the same time.
I'm wondering how WhatsApp application works and handles this logic. It also has GIF selection from Tenor. I already checked and figured out that WhatsApp downloads small video files and not gif images. That's why it loads very fast. But I have no idea how they can show 20+ items at the same time. HERE is how that works in WhatsApp - https://media.giphy.com/media/33E84h3RAVn0vQWZak/giphy.gif. Also, I notices during scroll the small static previews are showing, but I don't see the app making requests for it. Probably they gets a first frame of the gif on the fly without any delays in main thread.
I also tried that, but even if I make every single stuff in background thread and the only line on the main thread is "self.imageView.image = myImage", it anyway is lugging a little bit if I have 8 items in the row for example and scrolling very fast.
I see only 2 possible solutions to have it loads fast (so we definitely need to load mp4 instead of gifs), and scroll smooth and without lugs:
1. WhatsApp uses its own custom Video Core to display video in the UICollectionViewCell .
2. WhatsApp downloads video to speed up the download process but then encodes mp4 file to gif one on the fly and use regular animated UIImageView to show the output gif file. However I was not able to have this flow working very fast without lugging during 'massive' scrolling
Any thoughts on how to implement the same to make it works fast and smooth as in WhatsApp? I'm unable to check how it handles the downloaded info, but for sure it downloads mp4 files and not gif ones.
Is there a more 'best practices' way to implement a rotating image on launch screen? I'm currently using the SwiftGifOrigin library with a gif to accomplish this, and it's working well. (There's nothing else on the screen other than a tap gesture.) Since gifs aren't natively supported, I feel like what I'm doing must be wrong. I created the gif myself with the ffmpeg library and could take some time and implement the graphics programmatically in a carousel, but are there any serious cons to my current implementation?
I have an cordova ios application where I show a different gif upon swipe up and swipe up.
But when I swipe up the first gif the second gif doesn't start playing properly from it's first frame like it should.
Instead the second gif shows the last frame of the second gif first and then only it starts playing.
Please see the attached gif herewith.
Because of this it creates an ugly flicker on each image swipe up on the ipad app.
Could someone please point me out what I am doing wrong or what should I be doing differently to fix this issue ?.
I am tesing using ios 9.1.
I think I have a partial answer.
My problem resulted from splitting one rendered image sequence from After Effects into multiple animated gifs in Photoshop.
I think it must have something to do with the way the images are referenced in the image sequence that messes up the final animated gif. Possibly because it loses information about which images are first or last in the process.
I fixed the problem by rendering each image sequence separately then opening each image sequence in Photoshop and saving them as animated gifs separately as well.
I'm just trying to create a simple app, that would work as a wallpaper app. But i need to get the images off interwebs. So I thought I would get a rss feed of images and and basically have a rss reader that only has images. But I thought. . . I need a preview for the images in the main viewcontroller, so I would use just a image view for that, but it needs to be able to let the user be able to click on the preview image and take the user to another viewcontroller that will have the full size image. So should I try to put the preview images in a button? and let the button take the user to another viewcontroller with a full size imageview and somehow have the image display their. Sorry if this is confusing, this is the only way i thought how to do this. If their is an easier way, please tell me. And when it comes to, when the user wants to download the image online, i can just hook up some outlets for some buttons on the viewcontroller and link them together with the image, and put some code for saving the image. Would that work?
Ok, so let me get this straight:
You want to create an app that retrieves images from the internet, displays them to the user, and when the user clicks on an image, he/she is presented with a fullscreen view of that image?
There are a number of options you can pick from. Here are just a few suggestions:
You can use the image as the image for a UIButton
You can make the UIImageView call a function when it's tapped (using either a UIGestureRecognizer, or just implementing the touchesBegan: method).
You can put an invisible UIButton over the UIImageView
When displaying the image, you add an UIImageView to the UIViewController and hook it up using an IBOutlet (unless you're creating the layout in code). Then in the code, you would convert the downloaded image (NSData) into a UIImage, and then display this in the UIImageView.
It seems as you're a beginning iOS Developer, and I respect that you're trying to learn by doing. However, I suggest that you start off with reading some introductory tutorials before you begin your first project. Otherwise you might waste a lot of time. Here's a very good guide on how to get started! Good luck :)
I'm currently working on an UI to crop an image inside my app, and I'd like it to feel as native as possible. I looked to the iPad's built in Photos app for some ideas, and noticed that when you crop an image, instead of a blue "Done" button, it has a yellow tinted button that has "Crop" on it, like so:
Does anyone know how to replicate this? I recall that the UIKit framework had a bunch of artwork stored inside of it in some custom file format and an iOS app existed that was able to read this and save you the individual PNGs, but I do not remember what this app is called. Conveniently enough for me, the thing I remember is that this yellow button graphic was among those contained. Anyone got any ideas how I can replicate the button nevertheless?
(Although if anyone knows that utility, that'd be great.)
Try this:http://www.raywenderlich.com/4344/user-interface-customization-in-ios-5