2011-12-02 75 views
2

我在擴展TTThumbsViewController以顯示來自外部源的照片。一切工作正常,但我想改變控制器的一種行爲:我想在用戶仍在滾動時顯示/加載圖像TTThumbsViewController,而不僅僅是當用戶完成滾動時。TTThumbsViewController在滾動時顯示圖像

我看到​​當滾動開始時,請求被暫停,我試圖設置它不是NO,但它似乎只是獲取圖像,並沒有實際顯示它們,當他們完成加載。

//TTTableViewDelegate.m 
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView { 
    [TTURLRequestQueue mainQueue].suspended = YES; 
    ... 
} 

此外,我掛在開始和結束拖動代表呼籲,試圖刷新視圖每秒左右,與顯示縮略圖的希望,我已經打過電話invalidateViewreload和一對夫婦更在主線程但似乎沒有工作(invalidateModel不適合我這裏的目的)。

任何人都可以指向正確的方向嗎?

在此先感謝

EDIT1:有狀態欄加載器,如果我滾動,當我使用[TTURLRequestQueue mainQueue].suspended = NO;,但它實際上並沒有獲取相關的圖片,使用Wireshark證實。

EDIT2:多一點的調試,我發現該請求被編程發送,但我們完成滾動後的反應時只收到,這樣看來的NSURLConnection異步委託方法而scrollView被滾動不燒成後,但我設法在另一個視圖控制器中使用tableView做類似的代碼(工作),而不使用three20 lib。

回答

0

周圍的Googling多個線程,我終於實現了我想要的行爲的論壇,雖然我改變了,而不是在一部分伸出它three20代碼後:在我thumbsViewController我採取了以下的委託,允許在滾動時提出請求:

-(void)didBeginDragging { 
    [super didBeginDragging]; 
    [TTURLRequestQueue mainQueue].suspended = NO; 
} 

我們解決滾動時,我發現NSURLRequest won't fire while UIScrollView is scrolling在TTRequestLoader.m有用,我改變了以下不被處理的連接的問題:

//TTRequestLoader.m 
- (void)connectToURL:(NSURL*)URL { 
    ... 
    //To allow requests while scrolling we must schedule the conenction in other run loop 
    //_connection = [[NSURLConnection alloc] initWithRequest:URLRequest delegate:self]; 
    //code above was replaced by the one below 
    _connection = [[NSURLConnection alloc] initWithRequest:URLRequest delegate:self startImmediately:NO]; 
    [_connection scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSRunLoopCommonModes]; 
    [_connection start]; 
}