<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    Sealyu

    --- 博客已遷移至: http://www.sealyu.com/blog

      BlogJava :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
      618 隨筆 :: 87 文章 :: 225 評論 :: 0 Trackbacks

    We often need to add social features in our iPhone apps. Adding features like commenting, shouts etc are very common. These type of data are usually shown
    with pagination with buttons like next, previous etc.

    To reduce the overhead of creating this functionality again and again we may encapsulate the common functions in a class. So did I for my applications.

    I have created a class named PaginationAgent. After loading records it calls related methods of its delegate which should implement protocol PaginationAgentDeleagte.

    Additionally two php files are needed. One to return the total number of records and another one is to fetch the page data. They must be named respectively as

    • get_total_number_of_records.php
    • get_records.php

    Lets see an example.

    First, I have created a simple view based project “Pagination” and designed the view as u see:

    Create a similar view using Interface Builder

    1. Added a button to show previous page data

    2. One button to reload the data.

    3. Another to show data on next page.

    4. Added a UITable which will show the result.

    In PaginationViewController.h, imported PaginationAgent.h file and declared:

    1. PaginationAgent* objPagination;  

    Now lets see how to initialize it. In the viewDidLoad method I initialized this like this:

    1. objPagination = [[PaginationAgent alloc] init];  
    2. objPagination.delegate = self;  
    3. objPagination.remoteApiBasePath = @"http://your.server/path/to/folder";  

    remoteApiBasePath must be set to the location where the server side php files are placed.
    No trailing slash.

    PaginationAgentDelegate protocol declares the following functions to be overridden by the Delegate:

    1. /** 
    2. * This method is called when the busystate is changed. 
    3. * You can do something like disable/enable the buttons, grayout etc 
    4. * based on the isBusy value. 
    5. */  
    6. -(void)paginationAgent:(PaginationAgent*)agent updateBusyMode:(BOOL)isBusy;  
    7.   
    8. /** 
    9. * Called when total data count is received if shouldReloadAtFirstPage is set NO. 
    10. */  
    11. -(void)paginationAgent:(PaginationAgent*)agent totalDataCountReceived:(int)dataCount;  
    12.   
    13. /** 
    14. * Called when page data is loaded. You may set your table dataSource here and realod 
    15. * reload the table. 
    16. */  
    17. -(void)paginationAgent:(PaginationAgent*)agent pageDataReceived:(NSArray*)data;  
    18.   
    19. /** 
    20. * Called if server sends malformed data 
    21. */  
    22. -(void)paginationAgent:(PaginationAgent*)agent onPaginationServerError:(NSString*)message;  
    23.   
    24. /** 
    25. * Called if connection failed. It may occur due to poor or no internet connectivity 
    26. */  
    27. -(void)paginationAgent:(PaginationAgent*)agent onPaginationConnectionError:(NSString*)message;  

    The php files must return data in json format and must use the format as used:

    1. 1,'message'=>'Success','data'=>33);  
    2.     echo json_encode($data);  
    3.   
    4. ?>  
    1. ...  
    2. ...  
    3. $data = array('success'=>1,'message'=>'Got data','data'=>$rows);  
    4.   
    5. echo json_encode($data);  

    See the attached project for details. The php files are inside the folder “PHPFILES”.

    Pagination.zip

    posted on 2010-10-08 21:30 seal 閱讀(276) 評論(0)  編輯  收藏 所屬分類: iPhone
    主站蜘蛛池模板: 亚洲天堂视频在线观看| 亚洲毛片基地日韩毛片基地| 亚洲国产精品激情在线观看| 亚洲欧洲中文日韩av乱码| 亚洲最新视频在线观看| 亚洲午夜无码久久久久小说| 国产综合成人亚洲区| 2015日韩永久免费视频播放| 曰批全过程免费视频在线观看 | 四虎永久在线精品视频免费观看| 又粗又硬又黄又爽的免费视频 | 亚洲最大中文字幕无码网站| 人碰人碰人成人免费视频| 黄色网址免费大全| 亚洲精品无码国产| 污视频网站在线免费看| 岛国av无码免费无禁网站| 国产亚洲一区二区三区在线观看 | 亚洲成a人无码亚洲成www牛牛| 嫩草在线视频www免费观看| 午夜两性色视频免费网站| 亚洲码在线中文在线观看| 97人妻精品全国免费视频| 免费h成人黄漫画嘿咻破解版| 亚洲av片不卡无码久久| 午夜亚洲AV日韩AV无码大全| 99亚洲男女激情在线观看| 18禁美女裸体免费网站| 亚洲日本va午夜中文字幕一区| 人成午夜免费大片在线观看| 亚洲av高清在线观看一区二区| 亚洲日韩AV一区二区三区中文| 亚洲人成免费电影| 亚洲黄色在线观看| 在线视频免费观看爽爽爽| 亚洲一区电影在线观看| 欧美a级在线现免费观看| 亚洲а∨精品天堂在线| mm1313亚洲精品国产| 99久久99这里只有免费的精品| 亚洲人成精品久久久久|