Reprinted from: http://carlme.blog.163.com/blog/static/183716327201272421728204/
@interfaceFooterviewtestviewcontroller:uiviewcontroller<uitableviewdatasource, uitableviewdelegate>{//Tabular data arrays, as is the demo code, directly defined as an arrayNsmutablearray*Tabledata;//data that is displayed when the drop-downNsmutablearray*Tablemoredata;
//Number of dataNsuinteger Datanumber;//Load StateBOOL _loadingmore; UITableView*table;} @property (nonatomic, retain) UITableView*table; @property (nonatomic, retain) Nsmutablearray*Tabledata, @property (nonatomic, retain) Nsmutablearray*Tablemoredata;//CREATE TABLE Bottom- (void) Createtablefooter;//Start Loading Data- (void) Loaddatabegin;//in the load data- (void) loaddataing;//Load Data Complete- (void) Loaddataend;@end @implementationFooterviewtestviewcontroller@synthesizetable;@synthesizeTabledata;@synthesizeTablemoredata;- (void) viewdidload {[Super viewdidload]; Table= [[UITableView alloc] Initwithframe:cgrectmake (0,0, the,460) Style:uitableviewstyleplain]; Table.Delegate=Self ; Table.datasource=Self ; [Self.view addsubview:table]; Tabledata=[[Nsmutablearray alloc] Initwithobjects:@"January",@"February",@"March",@"April",@" May",@"June",@"July",@"August",@"September",@"October",@"November",@"December", nil]; Tablemoredata= [[Nsmutablearray alloc] Initwithobjects:@"BAIDU",@"GOOGLE",@"FACEBOOK",@"YAHOO", nil];
[Self createtablefooter];} #pragmaMark-#pragmaMark Table View Data source//Customize the number of sections in the table view.-(Nsinteger) Numberofsectionsintableview: (UITableView *) TableView {return 1;}//Customize the number of rows in the table view.-(Nsinteger) TableView: (UITableView *) TableView numberofrowsinsection: (nsinteger) Section {return[Tabledata Count];}//Customize The appearance of Table view cells.-(UITableViewCell *) TableView: (UITableView *) TableView Cellforrowatindexpath: (Nsindexpath *) Indexpath {StaticNSString *cellidentifier =@"Cell"; UITableViewCell*cell =[TableView Dequeuereusablecellwithidentifier:cellidentifier]; if(Cell = =Nil) {Cell=[[[ UITableViewCell alloc] Initwithstyle:uitableviewcellstyledefault Reuseidentifier:cellidentifier] Autorelease]; } Cell.textLabel.text=[Tabledata ObjectAtIndex:indexPath.row]; returncell;}- (void) Scrollviewdidenddragging: (Uiscrollview *) ScrollView willdecelerate: (BOOL) decelerate{//show more data when you drop down to the bottom if(!_loadingmore && scrollview.contentoffset.y > (ScrollView.contentSize.height-scrollView.frame.size.height)) {[Self loaddatabegin]; }} //Start Loading Data- (void) loaddatabegin{if(_loadingmore = =NO) {_loadingmore=YES; Uiactivityindicatorview*tablefooteractivityindicator = [[Uiactivityindicatorview alloc] Initwithframe:cgrectmake (75.0f,10.0f,20.0f,20.0f)]; [Tablefooteractivityindicator Setactivityindicatorviewstyle:uiactivityindicatorviewstylegray]; [Tablefooteractivityindicator startanimating]; [Self.table.tableFooterView Addsubview:tablefooteractivityindicator]; [Self loaddataing]; }} //in the load data- (void) loaddataing{Datanumber=[Tabledata Count]; for(intx =0; x < [tablemoredata count]; X + +) {[Tabledata addobject:[tablemoredata objectatindex:x]]; } [[Self table] reloaddata]; [Self loaddataend];} //Load Data Complete- (void) loaddataend{_loadingmore=NO; [Self createtablefooter];} //CREATE TABLE Bottom- (void) createtablefooter{Self.table.tableFooterView=Nil; UIView*tablefooterview = [[UIView alloc] Initwithframe:cgrectmake (0.0f,0.0f, Self.table.bounds.size.width,40.0f)]; UILabel*loadmoretext = [[UILabel alloc] Initwithframe:cgrectmake (0.0f,0.0f,116.0f,40.0f)]; [Loadmoretext SetCenter:tableFooterView.center]; [Loadmoretext setfont:[uifont Fontwithname:@"Helvetica Neue"Size -]]; [Loadmoretext SetText:@"pull up to show more data"]; [Tablefooterview Addsubview:loadmoretext]; Self.table.tableFooterView=Tablefooterview;}@end
UITableView Bottom Footerview implement pull-up refresh