I am trying to use PFImageView.loadInBackground() in iOS10 .
So far my code has worked in iOS9 etc.
This is what I am doing:
fetching image data
assigning data to PFImageView.file
loading file via PFImageView.file.loadInBackground()
The ImageData is found, but the image won't display.
Any ideas?
I had an issue with PFImageView when the file name for PFFile had white spaces.
Did you try running in Simulator what errors did you receive?
Related
I have a tableview and each cell will load Gif file from server.
I'm using Kingfisher to load Gif file into cell imageview like this:
cell.ivPost?.kf.setImage(with: url)
the Gif is loaded successfully, however the tableview is very laggy when scrolling down. I though that the loading, encode & decode gif file should be done asynchronously using Kingfisher
Anyone has solution for this?
I'm using xCode 8 and Swift 3
User this method
public func setImage(with resource: Resource?, placeholder: Image? = default, options: KingfisherOptionsInfo? = default, progressBlock: Kingfisher.DownloadProgressBlock? = default, completionHandler: Kingfisher.CompletionHandler? = default) -> Kingfisher.RetrieveImageTask
you can give options KingfisherOptionsInfo, which is an array of
KingfisherOptionsInfoItem
/// Decode the image in background thread before using.
case backgroundDecode
I've ended up using SDWebImage and it works smoothly with SDAnimatedImageView()
I use the following code to display UIImage loaded from Internet:
let imgURLString = "http://.../images/" + (self.userImage as String)
let imgURL = NSURL(string: imgURLString)
let imageData = NSData(contentsOfURL: imgURL!)
self.profilePictureImage.image = UIImage(data: imageData!)
That works good with the iphone5 simulator if the image is not too big.
But when I test it with my phone (ios9 iphone5), if I change the image on the server, the old image is still displayed.
I think there is a cache.
Is there a way to clear the cache? Or maybe a better approach to display images stored on a remote server?
Thank you for your feedback.
Regards,
Thomas
EDIT
I just found one interesting thing.
When I test in local network (through WIFI), it works fine with both simulator and iPhone.
But When I test remotely (through 4G), the image displayed is the old image. I have to connect the server with a web browser and refresh the images folder to make the new image display on the app.
Any idea to solve this?
I finally fixed it by changing the name of the new image stored on the remote server. Thus, I avoid any caching issue.
i'm sorry for my english.
i'm new in iphone development and happens to me a strange things.
I have a set of jpg images to show in a table view. When i test the app in iphone simulator everything is ok and work properly but when built and run the same code in iphone test device the same images aren't displayed.
Another strange behavior is that with a set of png images instead of jpg are shown perfectly in simulator like as in iphone test device.
Anyone can suggest me a solution?
I detect the name of image to load from a json file. This is the code that i use to show the image:
UIImageView *immaginePiadina = [[UIImageView alloc] initWithFrame:immagineValueRect];
[immaginePiadina setImage:[UIImage imageNamed:[item objectForKey:#"immagine"]]];
where [item objectForKey:#"immagine"] is an element of my json file like this:
"nome": "66",
"immagine": "pianetapiadabufalavesuviani",
"prezzo": "€ 7,50",
"nomeingrediente": [
"bufala",
"vesuviani"
]
How you can see i refer to the image with only the name of the file and without the file extension. I did it in this way to show image retina, it's wrong?
I exclude that i wrote a different case sensitive name because the png set works properly.
thanks a lot!!
There are possibly two separate issues that need separation, here is how to solve your problem.
First write a method using the NSFileManager, that given a file path verifies a file exists and has a size greater than 0. Insert a call to this everywhere you fail to open an image. If you use "imageNamed" then get the path to the bundle and create the path. If this method fails to find an image, fix it.
Second, the image decoding is different for the simulator and the device - the simulator uses the full OSX libraries. So take one image that fails to open and move it somewhere. Open it in Preview and export it using the same name but with png+alpha format. Change your code to expect a png not a jpg, and retest. Make sure you still use the first method to insure the file is there.
Once you get one success you can try other options, like using Preview exported jpegs. The reason this should work is that all of these image formats permit a huge range of options all of which iOS does not support.
Given that the current format us the problem, you can script changes using the "sips" program, which is what Preview uses.
I solve my problem using the following code:
NSString* path = [[NSBundle mainBundle] pathForResource:[item objectForKey:#"immagine"] ofType:#"jpg"];
NSLog(#"%#",path);
UIImage* theImage = [[UIImage alloc] initWithContentsOfFile:path];
I don't know the reason but in this way i haven't any problem to display jpg in my iPhone test device. Maybe because NSBundle specify also the extension of the file.
Thanks #David-h that directed me in the right way to solve my problem.
Check the extensions of your images. If you write .PNG, in the simulator is Ok, but not in the device.
I would like to share an image between two users using parse.com. My original idea was to simple pass the image url from the first user to the second to view/download. I have no issue uploading the image to parse.com , however I can't work out how to return the url. Is it possible to return the url?
There seems to be a solution for this on android Get link to image file at Parse.com but I can't find one for iphone.
Thanks in advance
In the Image save example of Parse.com, I found the image url.
In - (void)setUpImages:(NSArray *)images method,
PFFile *theImage = [eachObject objectForKey:#"imageFile"]; will return image file object with its URL.
Hope this will help you.
I am developing a unity app, in which i call webservice for image url and after getting those url, i call one by one url for image downloading and store those images onto disks, and after in some point i read those images from disks and show as texture, but i am getting problem in reading images. It show me Question mark on texture and when i dig more to find out problem i got that i am getting zero of image using www.size and text also nil using www.text. I am doing following for reading and writing images.
Writing
if(wwwMarker.isDone)
File.WriteAllBytes(Application.persistentDataPath + "/"+ data.markerName + ".jpg", wwwMarker.bytes);
Reading
//fileurl is string which contain path of file
fileUrl = (Application.persistentDataPath + "/"+ markerDataObject.markerName + ".jpg");
if(System.IO.File.Exists(fileUrl))
if(www.isDone)
video.mIconPlane.renderer.material.mainTexture = imageToLoadPath.texture;
But when i read this code and show render image on texture it show me Question mark image, but when i load images from assets it works perfectly fine. Please help me that where i am doing wrong. I am nee bee in unity so thats why doing silly mistakes. This will be great for me. Thanks in advance.
Note, that unity's WWW can only dowload and save as textures JPG and PNG images. If you will try to download an image of any other format, you will get a red "?" image as result.