Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add empty (blank) space under (in the end of) UITableView

My app has the UITableView which have variable quantity of cells inside.

How can I add empty (blank) space with certain height under the UITableView? Or in the very end of UITableView? So that after the very last cell there will be more blank space.

like image 668
Tung Fam Avatar asked Aug 16 '16 10:08

Tung Fam


3 Answers

Set the content inset on your table view:

var insets: UIEdgeInsets = tableView.contentInset
insets.bottom = 100
tableView.contentInset = insets

or, simply:

tableView.contentInset.bottom = 100

That will leave some blank space under the table view after you scroll to the last cell.

like image 175
Daniel Sumara Avatar answered Oct 20 '22 15:10

Daniel Sumara


It's honestly this simple:

Add the following, likely in viewDidLoad:

tableView.contentInset.bottom = 100

Really that's all there is to it.

override func viewDidLoad() {
    super.viewDidLoad()
    
    tableView.contentInset.bottom = 100
}
like image 43
Fattie Avatar answered Oct 20 '22 15:10

Fattie


You can use tableView Footer for that

UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.tableView.frame.size.width, 100)];
[self.tableView setTableFooterView:view];
like image 11
Nirav D Avatar answered Oct 20 '22 15:10

Nirav D