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

詳解iPhone Tableview分批顯示數(shù)據(jù)

移動開發(fā) iOS
iPhone Tableview分批顯示數(shù)據(jù)是本文要介紹的內(nèi)容,主要講解的是數(shù)據(jù)的顯示。iPhone屏幕尺寸是有限的,如果需要顯示的數(shù)據(jù)很多,可以先數(shù)據(jù)放到一個table中,先顯示10條,table底部有一察看更多選項,點(diǎn)擊察看更多查看解析的剩余數(shù)據(jù)。

iPhone Tableview分批顯示數(shù)據(jù)是本文要介紹的內(nèi)容,主要講解的是數(shù)據(jù)的顯示。iPhone屏幕尺寸是有限的,如果需要顯示的數(shù)據(jù)很多,可以先數(shù)據(jù)放到一個table中,先顯示10條,table底部有一察看更多選項,點(diǎn)擊察看更多查看解析的剩余數(shù)據(jù)。基本上就是數(shù)據(jù)源里先只放10條, 點(diǎn)擊***一個cell時, 添加更多的數(shù)據(jù)數(shù)據(jù)源中. 比如:

數(shù)據(jù)源是個array:

  1. NSMutableArray *items; 

ViewController的這個方法返回數(shù)據(jù)條數(shù): +1是為了顯示"加載更多"的那個cell

  1. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {  
  2.         int count = [items count];  
  3.     return  count + 1;  

這個方法定制cell的顯示, 尤其是"加載更多"的那個cell:

  1. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {  
  2.     if([indexPath row] == ([items count])) {  
  3.         //創(chuàng)建loadMoreCell  
  4.         return loadMoreCell;  
  5.     }  
  6.     //create your data cell  
  7.     return cell;  

還要處理"加載更多"的那個cell的選擇事件,觸發(fā)一個方法來加載更多數(shù)據(jù)到列表

  1. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {  
  2.       
  3.     if (indexPath.row == [items count]) {  
  4.         [loadMoreCell setDisplayText:@"loading more ..."];  
  5.         [loadMoreCell setAnimating:YES];  
  6.         [self performSelectorInBackground:@selector(loadMore) withObject:nil];  
  7.         //[loadMoreCell setHighlighted:NO];  
  8.         [tableView deselectRowAtIndexPath:indexPath animated:YES];  
  9.         return;  
  10.     }  
  11.     //其他cell的事件  

加載數(shù)據(jù)的方法:

  1. -(void)loadMore  
  2. {  
  3.     NSMutableArray *more;   
  4.         //加載你的數(shù)據(jù)  
  5.     [self performSelectorOnMainThread:@selector(appendTableWith:) withObject:more waitUntilDone:NO];  

添加數(shù)據(jù)到列表:

  1. -(void) appendTableWith:(NSMutableArray *)data  
  2. {  
  3.     for (int i=0;i<[data count];i++) {  
  4.         [items addObject:[data objectAtIndex:i]];  
  5.     }  
  6.     NSMutableArray *insertIndexPaths = [NSMutableArray arrayWithCapacity:10];  
  7.     for (int ind = 0; ind < [data count]; ind++) {  
  8.         NSIndexPath    *newPath =  [NSIndexPath indexPathForRow:[items indexOfObject:[data objectAtIndex:ind]] inSection:0];   
  9.         [insertIndexPaths addObject:newPath];  
  10.     }  
  11.     [self.tableView insertRowsAtIndexPaths:insertIndexPaths withRowAnimation:UITableViewRowAnimationFade];  
  12. }  

小結(jié):詳解iPhone Tableview分批顯示數(shù)據(jù)的內(nèi)容介紹完了,希望通過本文的學(xué)習(xí)能對你有所幫助!

責(zé)任編輯:zhaolei 來源: 互聯(lián)網(wǎng)
相關(guān)推薦

2011-07-29 10:51:41

iPhone 全屏顯示 視圖

2011-08-08 15:48:13

iPhone TableView 背景

2011-08-09 10:05:57

TableView服務(wù)器圖片

2011-07-20 15:49:40

iPhone 數(shù)據(jù) 進(jìn)度窗

2011-06-03 10:19:59

iphone Objective-

2011-08-17 15:19:38

iPhone應(yīng)用數(shù)據(jù)

2011-07-26 18:11:56

iPhone Sqlite 數(shù)據(jù)庫

2011-07-27 10:16:41

iPhone SQLite 數(shù)據(jù)庫

2011-07-27 15:47:09

iPhone Simulator 文件

2011-07-20 15:20:14

IPhone AVAudioRec

2011-08-02 17:27:06

iPhone應(yīng)用 剪切技巧

2011-07-08 17:45:19

iPhone 文檔

2011-08-10 17:37:00

iPhoneASIHTTPRequ

2011-08-02 16:28:40

iPhone Web開發(fā) 事件

2011-07-08 15:08:16

iPhone 圖片

2011-07-26 09:53:53

iPhone AsyncSocke 網(wǎng)絡(luò)

2011-08-22 12:01:38

iPhone開發(fā)文件

2011-08-15 11:37:20

iPhone開發(fā)Mask

2011-08-10 11:12:33

iPhone文件

2011-07-06 15:59:38

iPad iPhone iOS
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號

主站蜘蛛池模板: 日本三级电影在线免费观看 | 午夜小视频在线播放 | 国产欧美日韩精品一区 | 免费在线一区二区 | 色婷婷一区二区三区四区 | 黄a网| 久久大陆| 日韩在线观看一区 | 欧美综合视频 | 天天综合网永久 | 免费成人高清在线视频 | 久久久精品一区二区三区四季av | 国内精品伊人久久久久网站 | 91精品国产综合久久小仙女图片 | 久久一日本道色综合久久 | 欧美精品一区在线 | 91成人在线 | 欧美乱操 | 三极网站| 亚洲精品国产一区 | 欧美黑人体内she精在线观看 | 欧美一区二区成人 | 欧美日韩综合视频 | 亚洲不卡 | 国产精品96久久久久久 | 在线观看欧美日韩视频 | 亚洲精品在线视频 | 99日韩| 欧美性生活视频 | 美女操网站 | 亚洲91精品 | 欧美极品在线观看 | 亚洲综合天堂网 | 天天操伊人| 日本不卡高字幕在线2019 | 日韩在线免费视频 | 亚洲高清在线视频 | 精品综合久久 | 伊人久久伊人 | 亚洲一区在线日韩在线深爱 | 色婷婷综合久久久中字幕精品久久 |