Closed bobi33 closed 10 years ago
Create an instance of AMScrollingNavbarTableViewController
instead of UITableViewController
and call this:
[yourTableViewController followScrollView:yourTableViewController.tableView];
Thanks.
Also, setting up without cocoapods gives this error: No visible @interface for WebViewController declares the selector 'followScrollView'
Is your WebViewController
a subclass of AMScrollingNavbar
?
Thanks, that was the issue. Everything works fine except that when I use the following method it only scrolls to the the top of the screen, but doesn't show the navigation bar. :
-(BOOL)scrollViewShouldScrollToTop:(UIScrollView *)scrollView {
// This enables the user to scroll down the navbar by tapping the status bar.
[self showNavbar];
return YES;
}
What view controller are you trying to scroll to top? Is it the tableviewcontroller that you created programmatically? In that case you need to call showNavbar
on its instance.
It's actually a WebViewController.
Ok, so your self
is the instance of your WebViewController, which subclasses AMScrollingNavBar
, is this correct?
Yes.
Ok, got it. Add this line to your webviewcontroller:
self.webView.scrollView.delegate = self;
Checkout the sample in the latest commit for more info
Hey, that seems to fix the issue with the navigation bar reappearing, however it causes other issues for me...
It causes an issue with the web view fitting in the view controller. What I mean by this is that webviewcontroller ends up moving up the page, not fitting correctly on the view. This causes the web view to shift up 60px, which causes the top of the web view to be hidden by the navigation bar that reappears.
Try the latest code in commit fc84dbb, I made a small change in the showNavbar
method.
I copied the latest code. It fixes the issue of shifting the webView up, however, because the webView is apart of a navigation controller when I go back two pages to the initial navigation view controller page ("Home Page"), that viewController becomes shifted down by about 80px.
You have to give me more details, I can't recreate the issue right now.
Ok, so I'll explain my setup:
-I have a navigationController setup like this... -user presses a UITableViewCell in ViewController1, which takes them to ViewController2; -user presses a UITableViewCell in ViewController2 and it takes them to ViewController 3; -user presses a UITableViewCell in ViewController3 and it takes them to the WebView; -the WebView works fine in terms of the scrolling issue I previously told you about; -However, when the user presses back on the NavigationBar and ends up on ViewController2, there seems to be an 80px shift of the view downwards (so there is a white gap of about 80px right underneath the navigation bar).
That's weird, it's not that different from the sample project, that doesn't suffer from this issue. I also tried to reproduce the same structure (table->table->web) and I can't reproduce the issue. I suggest to check out the sample project and make sure that everything is properly configured.
Yeah it is weird. I will take another look at it...maybe I forgot to mention that ViewController3 is a UISearchBar and Display Controller.
That might be it, I haven't tested the control with a display controller yet.
Oh ok. Well if you do could you please let me know. Thanks for the help.
I've been really troubleshooting this issue to see if it's on my end and can't seem to find anything...
I updated the sample project, now it contains a searchbar with a display controller. It seems to work just fine. Just make sure to use autolayout.
Thanks. I tried the new project, however I can't understand why it is conflicting with mine. I still get that gap when I push back from the web view to ViewController2. I don't know if it has something to do with my setup. It shouldn't. However, I'm using ECSlidingViewController as my setup, so maybe it's conflicting with that?
That might be it, though I never tried that control, since I have my own implementation of a sliding view controller.
Ahhhh ok. That's unfortunate. I'm too invested in that control to change now lol. Thanks Andrea for your help. If you ever try that control keep me posted.
What if I programatically made a UITableViewController. There is no View where I can connect an IBOutlet for tableView, therefore
[self followScrollView:self.tableView]; --> will not work for me... how can I call this method in my case?