<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 :: 首頁(yè) :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
      618 隨筆 :: 87 文章 :: 225 評(píng)論 :: 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 閱讀(275) 評(píng)論(0)  編輯  收藏 所屬分類(lèi): iPhone
    主站蜘蛛池模板: 亚洲日韩欧洲乱码AV夜夜摸| 国产成人免费永久播放视频平台| 在线A亚洲老鸭窝天堂| 青草青草视频2免费观看| 四虎精品亚洲一区二区三区| 国产亚洲精品成人久久网站| 免费人成视频x8x8入口| 一级大黄美女免费播放| 亚洲乱亚洲乱妇无码麻豆| a在线观看免费视频| 亚洲电影一区二区三区| 97热久久免费频精品99| 亚洲精品国产日韩| 国产精品免费视频一区| 全部在线播放免费毛片| 亚洲色婷婷六月亚洲婷婷6月| 男人j进入女人j内部免费网站 | 91亚洲视频在线观看| 97免费人妻无码视频| 亚洲成a∨人片在无码2023| 亚洲特级aaaaaa毛片| 在线看片免费不卡人成视频| 亚洲人成网站18禁止| 亚洲一区精品伊人久久伊人| 美女视频黄a视频全免费网站色窝| 亚洲综合激情九月婷婷| 女人张开腿等男人桶免费视频 | 亚洲最大成人网色| 97人伦色伦成人免费视频| 免费视频精品一区二区| 午夜亚洲AV日韩AV无码大全| 成人无遮挡裸免费视频在线观看 | 最新亚洲成av人免费看| 日韩精品内射视频免费观看| 亚洲不卡影院午夜在线观看| 亚洲精品成a人在线观看| 91视频免费网址| 亚洲精品午夜无码电影网| 亚洲免费中文字幕| 污视频网站免费观看| 亚洲国产天堂久久综合网站|