Q:

Add a button at the last cell of UITableView

I currently have 2 UITableView to filter out 2 category,
my category is cat and dog, 1st UITableView that handles cat and 2nd UITableView that handles dog.
What i want is to have cat and dog into one UITableview,
so the in the UITableView, the first part will be the cats, and the second part is the dog. what i want to do is to put a button above the dog part where it will be used as a separator for two category.
this is the illustration:

the 2 cells in the top is the cat 
and the one cell in the bottom is a dog there should be a button in the middle of the two category as a seperator.

A:

Try this code.
@interface ViewController () <UITableViewDelegate, UITableViewDataSource> {
    NSArray *arrCat;
    NSArray *arrDog;
}

- (void)viewDidLoad {
    [super viewDidLoad];

    arrCat = @[@"Cat 1", @"Cat 2", @"Cat 3", @"Cat 4", @"Cat 5"];
    arrDog = @[@"Dog 1", @"Dog 2", @"Dog3 ", @"Dog4 ", @"Dog 5"];
}

I have Programatically create Header, You can also create it by creating xib.
Add UITableView delegate and DataSource like this.
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 2;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    if (section == 0) {
        return arrCat.count;
    }
    return arrDog.count;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *cellIdentifier = @"TableViewCell";

    TableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];

    if (cell == nil) {
        cell = [[[NSBundle mainBundle] loadNibNamed:cellIdentifier owner:self options:nil] objectAtIndex:0];
    }

    if (indexPath.section == 0) {
        cell.lblCategory.text = arrCat[indexPath.row];
    }
    else {
        cell.lblCategory.text = arrDog[indexPath.row];
    }
    return cell;
}

-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.frame.size.width, 60)];
    view.backgroundColor = [UIColor greenColor];

    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    button.frame = view.frame;
    button.titleLabel.textAlignment = NSTextAlignmentCenter;
    button.titleLabel.textColor     = [UIColor blackColor];
    [view addSubview:button];

    if (section == 0) {
        [button setTitle:@"CAT" forState:UIControlStateNormal];
    }
    else {
        [button setTitle:@"DOG" forState:UIControlStateNormal];
    }
    return view;
}

-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    return 60.0;
}

