I have used AsyncImageView lib to load image on iCarousel. It duplicated images when load finish an image from URL . Anybody has this problem?
Any solution for this?
EDITED: I have found solution!
Because I used Paging type so it just load 1 item at a time. So it retain the previous imageview,
what I should do is reset image in this ImageView by
imageview.image = nil;
before load another item.
I didn't try AsyncImageView before, I am not sure if that is a problem in the library itself or in the way you use it.
But I use SDWebImage and it doesn't cause the duplication problem, I recommend to give it a try :)
Related
I inserted a UIView with a image inside a Cell View like tha image bellow.
What i tried:
DispatchQueue.main.async {
self.hideProfileDescriptionView.addSubview(self.hidedescriptionLogo)
self.hideProfileDescriptionView.bringSubview(toFront:
self.hidedescriptionLogo)
self.cellDescriptionView.addSubview(self.hideProfileDescriptionView)
}
In the First time I call the UIVIewController, the image does not display, but in the second time I call UIViewController the image appears.
How can I solve that.
Thanks
In the first case Image didnt load fully and second time download is completed. If you dont to wait this installations You can use KingFisher repo https://github.com/onevcat/Kingfisher .
This repo is highly recommended. Also with this repo you can put laoder in UIImageView.
I realized that all cell content was not being displayed, so i discovered a flag that i did put on the code and i did disable that. Solved.
In my app activityIndicator is necessary. But, i don't want that default symbol. If i want to replace any other image by using SWIFT means, how can i? Kindly help me.
You can't customize the spinning thing in a UIActivityIndicator. What I suggest is that you make your own indication of activity; for example, use an animated UIImage:
let im = UIImage.animatedImageNamed("myImages", duration:1)
... and show it (in an image view, probably) as a way of suggesting that activity is occurring.
I want to know what is the best and most optimized way to draw UIImage in a custom UITableViewCell that has many elements in it (several images, 2 labels, gradient background). I read that drawRect is the recommended way to go with this since there are several subviews involved and its better to have them all composed as one view content using drawRect. But at the same time I read somewhere else that UIImageView is the preferred way to optimally handle images (caching, fast rendering, etc). I'd appreciate some enlightenment.
Thanks
AF
I would recommend UIImageView for its easiness of use. You can drag & drop it in the Interface Builder or just add it programmatically.
I went to an iPhone Tech Talk once, and a performance engineer said if you're using a UIImage in a UITableView you should add it with the class method [UIImage imageNamed:] to get the most efficient use of the class. Of course you would need to embed that in a UIImageView. I usually find any time there are class methods available to make something for you, Apple is very efficient at the way they do it.
I would suggest you to use
cell.imgView.image = [UIImage imageNamed:#"123.jpg"];
Hey all, here's the deal...
I've got a UIImage that is being loaded in the background via an NSURLConnection within a subclassed UIImageView. Until the data finishes downloading, a placeholder image is shown. The UIImage needs to be used by another, separate UIImageView, as well.
The problem I'm having is that if I set the second UIImageView's image property to that of the subclassed object before the download is complete, the second UIImageView never displays the downloaded image, since it's image prop is pointing to the placeholder.
Is there anyway to pass a pointer to a pointer between these two UIImageViews?
I've tried things like this:
imageView2.image = &[imageView1 image];
imageView2.image = *[imageView1 image];
But these don't seem to work. Any ideas?
Those pointers look particularly gross. The problem with doing it that way is that, even though you might be updating the data pointed to by those pointers, you are not notifying your UIImageView subclasses that the data has changed, and thus they don't know to redraw.
Instead of playing with that pointer mess, why not use Key-Value Observing instead? If you have a separate thread running that downloads the UIImage, you can just tell your UIImageViews to observe that property and when your downloader class is finished downloading all the data and has put it into the property, the views will get a notification and can then display the image.
Can't you just catch the connectionDidFinishLoading: message from the NSURLConnection and then set the second image?
I'm using the three20 project for my iPhone app. I've narrowed my problem down and I'm now just trying to re-create the 'Web Images in Table' example that comes with the project. I've copied the code exactly as in the project, with the exception that I do not use the TTNavigator (which the example does) but I am adding my TTTableViewController manually to a tabBar.
The problem is as follows; the images in the table should load automatically from the web, like in the example. But they only load after I scroll the table up and down.
In the console it clearly says it is downloading the images, and you see the activity indicator spinning like forever.. And unless I scroll up and down once, the images will never appear.
Anyone? Thanks in advance.
P.S:
If I'm using this code in any random UIView, It also doesn't work (only shows a black square):
TTImageView* imageView = [[[TTImageView alloc] initWithFrame:CGRectMake(30, 30, 100, 100)] autorelease];
imageView.autoresizesToImage = YES;
imageView.URL = #"http://webpimp.nl/logo.png";
[self.view addSubview:imageView];
If I put this code in my AppDelegate (right onto the window), it does work .. strange?
POSSIBLE SOLUTION:
Although I stopped using TTImageView for this purpose, I do think I found out what the problem was; threading (hence accepting the answer of Deniz Mert Edincik). If I started the asynchronous download (because basically that is all the TTImageView is, an asynchronous download) from anywhere BUT the main thread, it would not start. If I started the download on the main thread, it would start immediately..
Sounds like a threading problem to me, are you creating TTImageView in the main runloop?
I find one interesting thing. When I use combination TTTableViewController, TTTableViewDataSource and TTModel I have same problem with loading TTImageView. My problem was, that my implementation of Model methods 'isLoading' and 'isLoaded' don't return proper values after initialization of model. That forces me to call reload on model manualy in 'viewDidAppear' method and that causes image loading problem. So I repair my 'isLoading' and 'isLoaded' methods to both return 'NO' after Model init, and everything is fine.
When an image finishes loading try sending a reloadData message to the table view. This forces the table to recalculate the size of the rows and redraw the table. Just be careful that you don't start downloading the image again in response to this message.
I've written something similar to this where an image view will load its own image from the web.
Im my experience, when the image had loaded successfully but was not shown in its view, it was a case that the cell needed to be told to redraw.
When you scroll the table view, the cells are set to redraw when the come onscreen, which is why they appear when you scroll.
When the image loads, tell the cell that it is sitting in to redraw by sending it the message setNeedsDisplay.
That way, when the image finishes downloading, the cell its sitting in (and only that cell) will redraw itself to show the new image.
It's possible that you might not need to redraw the entire cell and might be able to get away with simply redrawing the image view using the same method call. In my experience, my table cells view hierarchy was flattened, so I had to redraw the whole cell.
I don't have an answer for what you want to do, but I will say that this is considered a feature, and the expected behavior. You use TTImageView in UITableView when you want to do lazy loading of images. TTImageView will only load the images whose frames are visible on the screen. That way, the device uses its network resources to download images that the user has in front of them, rather than a bunch of images that the user isn't even trying to look at.
Consider having a long list that may contain a couple hundred thumbnail images (like a list of friends). I know from experience that if you kick off 100+ image requests on older devices, the memory usage will go through the roof, and your app will likely crash. TTImageView solves this problem.
This is a thread problem. You can load the images by including the line:
[TTURLRequestQueue mainQueue].suspended = NO;
in - (void)didLoadModel:(BOOL)firstTime.