2011-04-19 33 views
0

的UIImageView setImage不工作我有具有每個單元(實際上我使用EasyTableView)內UIViews一個的UITableView和視圖內有3周的UIImageViews改變圖像的第二的每1/3。IOS:滾動時

的問題是,這些圖像只改變而沒有滾動發生。

我讀了一些關於這個問題,我發現人們建議使用NSRunLoop,但這是NSURLConnection加載外部圖像時,我使用「UIImage imageNamed」和UIImageView的setImage。我讀到的另一個建議是使用NSInvocationOperation,但沒有運氣。

NSInvocationOperation *invocation = [[NSInvocationOperation alloc] initWithTarget:self selector:@selector(changeProgress) object:nil]; 
[invocation start]; 

也許我做錯了,請幫忙!謝謝。

回答

0

一個朋友找到了解決辦法,我只好不計劃任務創建定時器,並把它添加到NSRunLoop,所以代碼會是這樣:

_timer = [NSTimer timerWithTimeInterval:1.0/3.0 target:self selector:@selector(update:) userInfo:nil repeats:YES]; 
    [[NSRunLoop mainRunLoop] addTimer:_timer forMode:NSRunLoopCommonModes]; 
+0

好了,對我來說,我這樣做時遇到巨大的滯後... – hfossli 2012-09-25 09:18:25

+0

(阻塞主線程滯後 - 不是因爲一個時間間隔,PARAM) – hfossli 2012-09-25 09:29:41

0
+0

我試過內setNeedsDisplay 「changeProgress」方法,但問題是在滾動時不調用changeProgress,它只是暫停我創建的定時器。並加入UIScrollViewDelegate到它打破EasyTableView :( – William 2011-04-19 23:22:46