GithubHelp home page GithubHelp logo

Comments (14)

dmur avatar dmur commented on May 16, 2024

This is definitely a hack, but I currently solve this problem as follows:

- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
  // Prevent the AMScrollingNavbar from creating a black gap the first time the feed is scrolled.
  if (scrollView.contentOffset.y > 0
      && CGRectGetMinY(self.tableView.frame) != 0) {
    CGRect frameAdjustedToPreventOffset = self.tableView.frame;
    frameAdjustedToPreventOffset.size.height += frameAdjustedToPreventOffset.origin.y;
    frameAdjustedToPreventOffset.origin.y = 0;
    self.tableView.frame = frameAdjustedToPreventOffset;
  }
}

from amscrollingnavbar.

andreamazz avatar andreamazz commented on May 16, 2024

Hi @dmur
The implementation is independent from the type of scrollview you want to attach it to, that's why there's no specific documentation for the tableview (in any case, the sample project shows the implementation for it).
you just need to call

[self followScrollView:self.tableView]

making sure that your navbar is not translucent.
The gap you are referring to might be an old issue that is now fixed in the latest version (that I'm waiting to push to cocoapods until I iron out a couple of issues), and you can get it by setting the :head symbol in your podfile, like so:

pod 'AMScrollingNavbar, :head'

I hope this helps.
Cheers

from amscrollingnavbar.

dmur avatar dmur commented on May 16, 2024

Thanks for that. Unfortunately, updating to the head commit does not resolve the issue for me, I still need to use the workaround above to avoid the black gap. It's not a navigation bar translucency issue, mine is opaque.

FWIW, I wasn't sure if UITableViewController was supported because the example "AMTableViewController" is actually a UIViewController subclass. Perhaps that's the difference here.

from amscrollingnavbar.

andreamazz avatar andreamazz commented on May 16, 2024

Yep, you're right, it's probably the UITableViewController.
The AMTableViewController is a UIVIewController because I rarely use UITableViewControllers, since I like to have control over the view's hierarchy, and that's a good example of why I do that.
The current implementation of the scrollingnavbar requires that the scrollable view is contained in another view, and that's not the case with the UITableViewController.
I'll see if I can work around this and release an update.
Thanks for your feedback!

from amscrollingnavbar.

andreamazz avatar andreamazz commented on May 16, 2024

After some tinkering I can safely say that it can't be done. When you try to resize the tableview, the infamous black bar appears. It happens even if you resize the table manually.
That's why I never use a UITableViewController, it's just too limited and always a pain. You should too stick with a plain UIViewController and add a UITableView yourself.

from amscrollingnavbar.

dmur avatar dmur commented on May 16, 2024

@andreamazz I tried switching to UIViewController, but when the navigation bar is contracted, I get an extra 44px space at the bottom of the table. I'm guessing this is because AMScrollingNavbar doesn't change the view's frame when it contracts the nav bar (i.e. intended behavior)? Or is this a bug? Thanks

from amscrollingnavbar.

andreamazz avatar andreamazz commented on May 16, 2024

Did you set the bottom constraint on your table to hug the bottom of its superview?

from amscrollingnavbar.

dmur avatar dmur commented on May 16, 2024

Yeah, I set the constraints as defined in the README (0 for all sides).

from amscrollingnavbar.

andreamazz avatar andreamazz commented on May 16, 2024

Hi @dmur
I made a quick video on how to implement the library in a UIViewController with a UITableView: https://vimeo.com/92721470
If you are still experiencing this issue, please let me know how does your setup differ from the one in the video.

from amscrollingnavbar.

dmur avatar dmur commented on May 16, 2024

Hey, cheers on the video -- loved the music :)

Unfortunately I couldn't tell if the example in the video has the same issue as I'm describing or not. The problem would be visible if, after integrating the scrolling navbar, when you scroll to the bottom of the table, there is a gap == 44px (because the frame of the table view no longer extends to the bottom of its superview).

Our setup is different in that we have a tab bar at the bottom. However I've a few minutes now, so I'll go ahead and replicate your example and then confirm whether or not that setup demonstrates the same issue.

from amscrollingnavbar.

dmur avatar dmur commented on May 16, 2024

Actually, looks like this is unrelated to this project, just has to do with using UITableView within a UIViewController that's embedded in a tab bar. To fix I just had to redo the constraints after adding the view controller relationship to the tab bar. Sorry for the trouble.

from amscrollingnavbar.

andreamazz avatar andreamazz commented on May 16, 2024

No trouble at all. I'm glad it's working.
Cheers

from amscrollingnavbar.

 avatar commented on May 16, 2024

I'm also getting the black bar when using a UITableViewController (I have to use a UITableViewController) – I have read the comments above but can't understand how to resolve the issue, can you advise @dmur @andreamazz ? Thank you

from amscrollingnavbar.

dmur avatar dmur commented on May 16, 2024

@dawson See my ugly hack above to work around the black bar, in the second post. Just use that implementation for your scrollViewDidScroll in the UITableViewController (it's a UIScrollViewDelegate as well, since UITableViewDelegate inherits from UIScrollViewDelegate), and it should remove the black bar. However, also note that I have not used that code in production, and it could have some unintended bugs!

from amscrollingnavbar.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.