Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: TableView section headers hide behind the Navigation bar in iOS 7 #181

Open
guidedways opened this issue Mar 4, 2014 · 22 comments
Open

Comments

@guidedways
Copy link

If you're using a Translucent UINavigationController and you have section headers in your UITableView, the section header moves up and hides under the nav-bar.

@jslim89
Copy link

jslim89 commented Mar 18, 2014

I have the same issue here. Before refresh, it shows correctly, but once refreshed, the first cell was hide behind the navigation bar

@kavichen
Copy link

kavichen commented Apr 2, 2014

just add navigationViewController.NavigationBar.translucent = NO into your code, solved!

@gmwood
Copy link

gmwood commented Apr 2, 2014

if you want to keep the translucent navigation bar you can set the content offset yourself after you call stopAnimating.

@Sean-Wang
Copy link

if ([self respondsToSelector:@selector(automaticallyAdjustsScrollViewInsets)]) {
    self.automaticallyAdjustsScrollViewInsets = NO;

    UIEdgeInsets insets = self.tableView.contentInset;
    insets.top = self.navigationController.navigationBar.bounds.size.height +
    [UIApplication sharedApplication].statusBarFrame.size.height;
    self.tableView.contentInset = insets;
    self.tableView.scrollIndicatorInsets = insets;
}

[tableView addPullToRefreshWithActionHandler:^{
// prepend data to dataSource, insert cells at top of table view
// call [tableView.pullToRefreshView stopAnimating] when done
}];

@RodBarnes
Copy link

Under Xcode 5, there are options on the view controller to "Extend Edges" - "Under Top Bars", "Under Bottom Bars". Just uncheck those. This fixed it for me.

@xiuchundao
Copy link

I agree with @Sean-Wang 's solution. But another problem occurs. When you pull down, PullToRefresh is triggered, it's right. While InfiniteScrolling will also be triggered, this should not be happened. How can I solved it ? Thanks very much.


I get the solution. see here if anyone need it. #163

@honus
Copy link

honus commented Jul 9, 2014

The problem appears to be that the pullToRefreshView remembers what the insets are at the time you call addPullRefreshWithActionHandler:. If you do this in viewDidLoad:, the view hasn't been added to the UINavigationController yet so the insets have not been correctly calculated yet. So instead of calling it there, call it in didMoveToParentViewController:

-(void)didMoveToParentViewController:(UIViewController *)parent {
    [super didMoveToParentViewController:parent];
    if (self.collectionView.pullToRefreshView == nil) {
        [self.collectionView addPullToRefreshWithActionHandler:^{
            //do refresh
        }];
    }
}

This way it remembers the correct value to put the content offset back to. If you do this, you don't need to implement @woodappsllc's or @Sean-Wang's suggestions.

@xiuchundao
Copy link

Hi, @honus . I think your suggestion is more elegant. So I take yours. Thank you very much.

@edison7500
Copy link

Hi, @honus thanks. fix SVPullToRefresh in iOS 7 Problem 👍

@MikeKogan
Copy link

This really fixed it without all the baloney of updating insets which becomes problematic during rotation.

Not only do you need:
self.automaticallyAdjustsScrollViewInsets = NO;

But this really fixes things on iOS7 without screwing with the content insets etc. Also works properly with custom cells, section headers, etc for the tableview.

self.edgesForExtendedLayout = UIRectEdgeNone;

Until I found this I was about to toss this library in the trash and just code it up myself. Too many bugs here for something that should be simple, but that's the Crapple way - make the simple complex. All of this is a piece of cake on Android...

@haitaowu
Copy link

Thanks @honus ,your suggestion is great.

@pblondin
Copy link

@MikeKogan, your solution is even better. Thanks!

@Shagans982
Copy link

@honus is correct, simply moving the handler into viewDidAppear did it for me.

@aryaxt
Copy link

aryaxt commented Mar 22, 2015

Same here. Moving handler to viewDidAppear did the trick, thanks

@bap2pecs0
Copy link

@kavichen thanks for the solution. Just add the Swift version which solved my problem: self.navigationController?.navigationBar.translucent = false

@aryaxt
Copy link

aryaxt commented May 27, 2015

I rather keep the nav bar translucent.

self.automaticallyadjustsscrollviewinsets = NO;

and call addPullToRefreshWithActionHandler in viewDidAppear

@Sean-Wang
Copy link

Thanks @MikeKogan, your solution is even better.

@liruqi
Copy link

liruqi commented Nov 20, 2015

You need to add action handler in - viewDidAppear method (or after), as you can get correct scroll view contentInset then. In - viewDidLoad, your scroll view has not set the final contentInset after in iOS7 or later, typically all zeros.

- addPullToRefreshWithActionHandler method record current scrollview contentInset as originalTopInset, originalBottomInset, and reset to that contentInset after - stopAnimating.

@haikieu
Copy link

haikieu commented Dec 13, 2015

@honus : thank you! It works

@eduardoarenastk
Copy link

It works, but now the activity loading view don't appear in the beginning. it's behind of the navigation bar.

@ryderjack
Copy link

@honus brilliant!

@ngheungyu
Copy link

ngheungyu commented Jun 11, 2016

if put in viewDidAppear..... this will make [self.scrollView triggerPullToRefresh] useless, if you want to trigger immediately after addPullToRefreshWithActionHandler

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests