Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Show UITableView Overflow?

I have a UITableView with a UIView transparent over it. It looks really cool. The fact that you can see beyond the UITableView.

My problem is that if I make the UITableView extend to the end of the UIView, you can't scroll to see the last one.

I tried adding a cell but the sizes don't match up and it looks kinda funny. What's the best solution to this?

Thanks, Coulton

enter image description here

like image 465
iosfreak Avatar asked Dec 13 '22 12:12

iosfreak


1 Answers

As table views are scroll views, you can give your table view a bottom inset, which works like bottom padding to push your cells some distance off the bottom edge of your table view.

CGFloat heightOfYourTabBar = 50;
UIEdgeInsets insets = UIEdgeInsetsMake(0, 0, heightOfYourTabBar, 0);

[self.tableView setContentInset:insets];
[self.tableView setScrollIndicatorInsets:insets];

The region of your table view that shows under your tab bar will continue to be visible, but the "bottom" of your cells is pushed up to the top. This way, you can scroll all the way to your last cell without it being obscured by your tab bar.

Scroll views and content insets are covered in the Configuring The Scroll View Content Size, Content Inset, And Scroll Indicators section of Apple's Scroll View Programming Guide for iOS. There's an example for the Photos app, which is exactly the pattern you'll mimic for your app by adding insets.

like image 162
BoltClock Avatar answered Dec 26 '22 10:12

BoltClock