【原創】開源中國閱讀小記

來源:互聯網
上載者:User

首先看TableView擷取cell執行個體的方法

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

涉及Cell執行個體化的代碼:

PostCell *cell = (PostCell * (!                NSArray *objects = [[NSBundle mainBundle] loadNibNamed: (NSObject *o ([o isKindOfClass:[PostCell = (PostCell **singleTap =            cell.img.image = [UIImage imageNamed:*p = ([cell.img.gestureRecognizers count] > *tap = (UITap *)[cell.img.gestureRecognizers objectAtIndex:                    tap.tag == self.catalog <=  ?  : == [UIFont boldSystemFontOfSize:= [NSString stringWithFormat:= [NSString stringWithFormat:                cell.img.image =  ([p.img isEqualToString:= [UIImage imageNamed:                    NSData * imageData ===                        IconDownloader *downloader = [imageDownloadsInProgress objectForKey:[NSString stringWithFormat: (downloader ==                            ImgRecord *record = [ImgRecord = cell;

下一步,startIconDownload: forIndexPath:中的實現,簡要而言,就是做以下幾件事:

1. 執行個體化IconDownloader,並將其set到imageDownloadsInProgress中

2. iconDownloader的執行個體則使用

NSURLConnection *conn =:self];

進行非同步請求

3. 當conn執行完畢,執行它的delegate - IconDownloader的finish方法,在這個方法中緩衝image

4. finish方法中,調用delegate - PostView,將ImageData通過UIImagePNGRepresentation渲染為image(png) data,並調用[tablePosts reloadData]

 

這裡,值得商榷的是:每一張圖片載入完畢都調用一次reloadData的方式是否是最優?

 

 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.