How to load animated GIF image as UIImage from *.imageset folder with different resolutions, without any additional pods?
If i put my GIF images in *.imageset folder they correctly display in XCode http://take.ms/7fsCp, but when i try to load it with UIImage, it returns nil
UIImage *image = [UIImage imageNamed: #"help_image"];
How to make it works?
You can use SDWebImage to do that.
#import "UIImage+GIF.h"
self.imageViewGif.image= [UIImage sd_animatedGIFNamed:#"help_image"];
I hope this can help you.
Add animated Gif image in Iphone UIImageView
check this link you will get your answer Using UIImage category you can get the exect output.
Related
When I use image picker to take photos using iPad camera , the photos are automatically getting resized/cropped while storing it.The same code is working fine with iPhone.Can anyone please help me to find out a solution for this. I am getting this in iOS 9.x.I need original images to be displayed.
Thank you very much in advance.
My issue got resolved when I changed
UIImage * image = info[UIImagePickerControllerEditedImage];
to
UIImage * image = info[UIImagePickerControllerOriginalImage];
in didFinishPickingMediaWithInfo method.
I am working on iOS application using new version Xcode 7 and iOS 9. I am facing the following issue.
UIImageView is not showing images coming through URL. I am using the following code but imageview did not show images.
NSURL *url = [NSURL URLWithString:#"http://XXX.XX.XX.XXX:XXXX/XXXXXXXX/7339bec316b7404299c582f5904a6d3f.jpeg"];
NSData *data = [[NSData alloc]initWithContentsOfURL:url];
UIImage *img = [[UIImage alloc]initWithData:data ];
imageview.image=img;
I don't know what is the issue in Xcode 7, but it is working previous version.
Thanks in advance,
The above code should work for synchronous loading of image into ImageView. Make sure URL and imageView code is right. Alternatively you can use SDWebImage for loading of images into imageView. It has Asynchronous loading, caching and many more options like post response processing which are very useful. It's very simple to implement too. Sample code is below.
#import <SDWebImage/UIImageView+WebCache.h>
[_profilePic sd_setImageWithURL:[NSURL URLWithString:imageUrl]
placeholderImage:[UIImage imageNamed:#"placeholderIcon"]];
This will populate your imageView with a placeholder and when the image is fetched it replaces placeholder with it. Check out the github project for more options.
I'm attempting to load images from my LaunchImage image set in a .xcassets file, but I don't want do use imageNamed:, as it wastes memory and the image only needs to be displayed for a couple of seconds during initial launch.
I have tried multiple approaches to this, but so far I have only been able to load them using imageNamed:.
This works:
[UIImage imageNamed:#"LaunchImage-700-568h.png"]
This doesn't work (returns null):
[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:#"LaunchImage-700-568h" ofType:#"png"]]
Is there any way to do this without adding the resources explicitly to the target (aside from the assets file)? Thanks!
Looks like the answer to your question is no.
According to XCAssets documentation.
Each set in an asset catalog has a name. You can use that name to programmatically load any individual image contained in the set. To load an image, call the platform specific class method, passing in the name of the set that contains the image. The OS will load the image from the set that is most appropriate for the current scale factor. The platform method for iOS is imageNamed:. For OS X the platform method is imageNamed:
So we must use [UIImage imageNamed:] method to load images from XCAssets catalog on iOS.
See similar question and answers here.
I m getting more than 200 image url from web service and i am converting image url to UIImage array and showing animation in UIImageView and its crashing in device and its working fine in simulator? Can you plz provide any solution for this issue.
I think you should handle this job by using the native API:
[UIImage +animatedImageWithImages:(NSArray *)images duration:(NSTimeInterval)duration]
I have a problem with the UIImagePickerController component. Currently in my app the user can pick an image from the saved photos library with the picker, no problems there.
However, it seems that if I crop and save a photo in Photos.app before picking the image, UIImagePickerController gives me the original uncropped version in the UIImagePickerControllerOriginalImage dictionary key.
I understand that UIImagePickerControllerEditedImage works when the crop is done inside the picker, but when done in the Photos app this key returns nil.
So my question is, how do I access the correct version of the image (without rolling my own picker with ALAssetLibrary)?
The solution was simple; I was using UIImagePickerControllerSourceTypeSavedPhotosAlbum instead of UIImagePickerControllerSourceTypePhotoLibrary.
What is your
-(void)imagePickerController:(UIImagePickerController *)pickr didFinishPickingMediaWithInfo;
method like?
Have you tried to do something like
-(void)imagePickerController:(UIImagePickerController *)pickr didFinishPickingMediaWithInfo:(NSDictionary *)info{
UIImage *image = [info objectForKey:UIImagePickerControllerEditedImage];
[myImageView setImage:image];
[pickr dismissModalViewControllerAnimated:YES];
}
(in the example it's UIImagePickerControllerEditedImage, don't know if you set YES to your picker allowEditing)