I am having a common footer for all cells and I am setting it with
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
I know that by default footers are sticky to bottom of UITableView, I dont want footers to stick to bottom of table, what is best way to achieve this?
One way I know is to add extra row and show footer there, But I am looking for cleaner approach than this.
Can anyone help me with this?
You can set UITableViewStyle
as UITableViewStyleGrouped
.
Use this initializer.
- (instancetype)initWithFrame:(CGRect)frame style:(UITableViewStyle)style;
You can set this on storyboard.
You can create an extra uitableviewcell
and append at the last of tableview. In the numberOfRowsInSection:
method you can add one 1 like
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [objectArray count]+1 ;
}
in tableView:cellForRowAtIndexPath:
method
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
if(indexpath.row == [objectArray count]) {
//create footer cell
}
else {
//show normal cell
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With