成人免费xxxxx在线视频软件_久久精品久久久_亚洲国产精品久久久_天天色天天色_亚洲人成一区_欧美一级欧美三级在线观看

iPhone學習之路 Table實現動態加載圖片

移動開發 iOS
本文介紹的是iPhone學習之路 Table實現動態加載圖片,主要講述的是對圖片的操作,我們來看內容。

iPhone學習之路 Table實現動態加載圖片是本文要介紹的內容,內容不多,基于代碼實現,我們一起來看內容。

Iphone在加載列表時,如果每個等待把所有列表中的數據都加載完在顯示相關內容,如果列表中有一些比較大的圖片,加載的時間比較長,那么給用戶的效果就很差了,下面詳細是一種實現動態加載圖片的辦法:

  1. - (UITableViewCell *)tableView:(UITableView *)tableView   
  2.          cellForRowAtIndexPath:(NSIndexPath *)indexPath {   
  3.     UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:@"tag"];   
  4.     if (cell==nil) {   
  5.         cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle   
  6.                                        reuseIdentifier:@"tag"] autorelease];   
  7.     }      
  8.     //表格設計   
  9.     NSDictionary* one = [array objectAtIndex:indexPath.row];   
  10.     cell.textLabel.text = [one objectForKey:@"title"];   
  11.     cell.detailTextLabel.text = [one objectForKey:@"content"];   
  12.      [NSThread detachNewThreadSelector:@selector(updateImageForCellAtIndexPath:) toTarget:self withObject:indexPath];   
  13.     return cell;   
  14. }   
  15.  
  16. - (void)updateImageForCellAtIndexPath:(NSIndexPath *)indexPath   
  17. {   
  18.     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];   
  19.     UIImage *image = [self getImageForCellAtIndexPath:indexPath];   
  20.     UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath];   
  21.     [cell.imageView performSelectorOnMainThread:@selector(setImage:) withObject:image waitUntilDone:NO];   
  22.     [image release];   
  23.     [pool release];   
  24. }   
  25. -(UIImage *)getImageForCellAtIndexPath:(NSIndexPath *)indexPath   
  26. {   
  27.     id path = [[array objectAtIndex:indexPath.row] objectForKey:@"image"];   
  28.     NSURL *url = [NSURL URLWithString:path];   
  29.     NSData *data = [NSData dataWithContentsOfURL:url];   
  30.     UIImage *image = [[UIImage alloc] initWithData:data cache:NO];   
  31.     return image;   

源代碼:http://easymorse-iphone.googlecode.com/svn/trunk/WelcomePavilion/

小結:iPhone學習之路 Table實現動態加載圖片的內容介紹完了,希望本文對你有所幫助!

本文來自:http://wangjun.easymorse.com/?p=908

責任編輯:zhaolei 來源: 互聯網
相關推薦

2011-07-25 15:32:06

iPhone Table 動態

2011-07-06 16:15:46

iPhone 圖片

2011-07-26 09:32:08

iPhone 模擬器

2023-10-10 15:32:09

veImageXWeb 圖片

2011-07-25 16:47:01

HTTP Server PUSH

2023-04-25 17:24:31

veImageXiOSSDK

2011-08-10 16:44:56

iPhone代理設計模式

2011-07-08 15:08:16

iPhone 圖片

2013-06-27 11:16:27

Android異步加載

2011-07-22 13:30:52

JavaScript

2011-07-21 17:29:42

iPhone Sqlite 數據庫

2009-08-28 16:14:26

C#實現加載動態庫

2011-07-27 17:07:06

iPhone 游戲 Cocos2d

2011-08-19 11:10:31

iPhone應用

2014-07-28 14:04:26

2011-08-16 18:13:42

IPhone開發UIView動畫

2021-10-18 12:04:22

Spring BootJava開發

2021-10-18 10:36:31

Spring Boot插件Jar

2022-09-23 15:01:33

圖片加載代碼

2011-08-02 14:23:09

iPhone UIScrollVi 圖片
點贊
收藏

51CTO技術棧公眾號

主站蜘蛛池模板: 国产精品99久久久久久动医院 | av无遮挡 | 人人99 | 久久狠狠| 精品日韩一区 | 欧美一区二区三区日韩 | 日韩久久精品 | 欧美日韩黄色一级片 | 欧美在线一区二区三区 | 蜜桃毛片 | 91免费电影| 台湾a级理论片在线观看 | 国产成人精品一区二区三区四区 | 日韩一级电影免费观看 | 一区二区精品 | 91激情视频 | 欧洲色综合 | 国产在线观 | 国产精品视频网 | 国产一区二区三区四区三区四 | 亚洲精选一区 | 欧美影院 | 97视频在线观看网站 | 国产美女久久久 | 成人精品在线观看 | 欧美99| 国产精品成人一区二区三区 | 国产精品久久久久久久久免费 | 精品成人免费视频 | 国产精品一区二区在线 | 亚洲一区二区三区在线 | 亚洲视频在线观看 | 97精品超碰一区二区三区 | 中文字幕在线视频免费观看 | 免费中文字幕 | 草久久久 | 亚洲一区二区视频在线播放 | 色www精品视频在线观看 | 99精品视频在线观看 | а天堂中文最新一区二区三区 | 亚洲欧美日韩系列 |