UITableView scroll indicator under UINavigationBar after changing contentEdgeInset

I have a UINavigationController that can display data as a UICollectionView or in a UITableView . iOS 7 automatically adjusts the scroll insert for the first UIScrollView created in the view hierarchy.

So, the UICollectionView is fine, but I have to set the contentEdgeInset for the UITableView . After this line

self.tableView.contentInset = UIEdgeInsetsMake(44.0f, 0.0f, 0.0f, 0.0f);

the content in the UITableView shown well, but the scroll indicator does not stop at the UINavigationBar , but will continue it.

How to enable this and stop the scroll indicator at the beginning of the UINavigationBar ?

enter image description here

+6
source share
1 answer

You can also set scrollIndicatorInsets as follows:

 self.tableView.scrollIndicatorInsets = UIEdgeInsetsMake(44.0f, 0.0f, 0.0f, 0.0f); 

By the way, on iOS 7 you should use [self.topLayoutGuide length] instead of hard coding 44.0f pixels. From the iOS 7 Transition Guide :

The topLayoutGuide and bottomLayoutGuide properties indicate the location of the upper or lower border of the bar in the view controllers view.

+11
source

All Articles