把tableveiw 的footerview 在footer上添加加载更多 的button
UIButton *btn=[UIButtonbuttonWithType:UIButtonTypeCustom];
[btnsetFrame:CGRectMake(0, 0, 320, 40)];
[btn setTitle:@"更多精彩" forState:UIControlStateNormal];
[btn setTitleColor:[UIColorredColor] forState:UIControlStateNormal];
[btn addTarget:selfaction:@selector(Loadmore)forControlEvents:UIControlEventTouchUpInside];
self.Table.tableFooterView=btn;
-(void)Loadmore
{
NSMutableArray *mutableArray=[[NSMutableArrayalloc]initWithCapacity:1];
for(int i=[self.dataSourcecount];i<[self.dataSourcecount]+7;i++)
{
NSIndexPath *indexPath=[NSIndexPathindexPathForRow:i inSection:0];
[mutableArrayaddObject:indexPath];
}
//记住这里要增加的数据是需要和前面声明的tabeview 初次加载的数据是一样的哦
for (int i=0; i<7; i++)
{
NSString *str=[NSStringstringWithFormat:@"第%d行",i];
[self.dataSourceaddObject:str];
}
[self.tableViewinsertRowsAtIndexPaths:mutableArray withRowAnimation:UITableViewRowAnimationFade];
}