Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UITableView scroll indicator under UINavigationBar after modifying contentEdgeInset

I have a UINavigationController that can show data as UICollectionView or in UITableView. iOS 7 automatically adjust scroll view inset for the first UIScrollView founded in the view hierarchy.

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

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

content in UITableView are shown well, but the scroll indicator doesn't stop at the UINavigationBar, but continue under it.

How can I resolve this and stop the scroll indicator at the begin of UINavigationBar ?

enter image description here

like image 345
Fry Avatar asked Apr 02 '14 12:04

Fry


1 Answers

You can also set the 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 top or bottom bar edges in a view controller’s view.

like image 140
Vinny Coyne Avatar answered Nov 18 '22 22:11

Vinny Coyne