iOs: UIImageView setImage not working while scrolling
I have an UITableView which has UIViews inside each cell (actually I'm using EasyTableView) and inside that view there are 3 UIImageViews changing images every 1/3 of a second.
The problem is, that the images change only while there's no scrolling happening.
I read some issues about this and I found people suggesting the use of NSRunLoop, but that's for NSURLConnection when loading external images, I'm using "UIImage imageNamed" and UIImageView's setImage. The other suggestion I read was to use NSInvocationOperation, but had no luck with that either.
NSInvocation开发者_StackOverflowOperation *invocation = [[NSInvocationOperation alloc] initWithTarget:self selector:@selector(changeProgress) object:nil];
[invocation start];
Maybe I'm doing it wrong, please help! Thanks.
Did you try this?
UIScrollView redrawing content while scrolling?
A friend found the solution, I had to create the timer without scheduling it, and add it to the NSRunLoop, so the code would be like this:
_timer = [NSTimer timerWithTimeInterval:1.0/3.0 target:self selector:@selector(update:) userInfo:nil repeats:YES];
[[NSRunLoop mainRunLoop] addTimer:_timer forMode:NSRunLoopCommonModes];
精彩评论