Первый набор Global int Переменная:
@interface TableViewController () {
int arrNum;
}
@end
@implementation TableViewController
- (void)viewDidLoad {
[super viewDidLoad];
arrNum = 3;
}
Затем установите количество разделов:
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 2;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
if (section == 0){
return arrNum;
}else {
return 5;
}
}
Затем создайте кнопку в нижнем колонтитуле раздела:
-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
UIButton *btn = [[UIButton alloc]init];
[btn setTitle:@"btn Click" forState:UIControlStateNormal];
[btn setBackgroundColor:[UIColor blueColor]];
[btn addTarget:self action:@selector(btnClk) forControlEvents:UIControlEventTouchDown];
return btn;
}
теперь задайте необходимое действие при нажатии кнопки:
-(void)btnClk {
arrNum = arrNum + 2;
dispatch_async(dispatch_get_main_queue(), ^{
[self.tableView reloadData];
});
}