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

UITableViewController "out of box" install yields black gap #44

Closed
dmur opened this issue Apr 14, 2014 · 14 comments
Closed

UITableViewController "out of box" install yields black gap #44

dmur opened this issue Apr 14, 2014 · 14 comments
Labels

Comments

@dmur
Copy link

dmur commented Apr 14, 2014

Hi, thanks for this great library. 👍

I couldn't find any documentation on using the project with UITableViewController, and when I use it with a table view controller "out of the box":

[self followScrollView:self.tableView]

there is a 64px gap added to the frame as soon as I start scrolling.

  1. How do I get rid of that gap?
  2. Since this is likely the most common integration scenario, it seems like documentation should exist for this.
@dmur dmur changed the title Document how to use with UITableViewController UITableViewController "out of box" install yields black gap + documentation request Apr 14, 2014
@dmur dmur changed the title UITableViewController "out of box" install yields black gap + documentation request UITableViewController "out of box" install yields black gap (+ documentation request) Apr 14, 2014
@dmur
Copy link
Author

dmur commented Apr 14, 2014

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;
  }
}

@andreamazz
Copy link
Owner

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

@dmur
Copy link
Author

dmur commented Apr 15, 2014

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.

@andreamazz
Copy link
Owner

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!

@dmur dmur changed the title UITableViewController "out of box" install yields black gap (+ documentation request) UITableViewController "out of box" install yields black gap Apr 15, 2014
@andreamazz
Copy link
Owner

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.

@dmur
Copy link
Author

dmur commented Apr 21, 2014

@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

@andreamazz
Copy link
Owner

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

@dmur
Copy link
Author

dmur commented Apr 23, 2014

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

@andreamazz
Copy link
Owner

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.

@dmur
Copy link
Author

dmur commented Apr 23, 2014

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.

@dmur
Copy link
Author

dmur commented Apr 23, 2014

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.

@andreamazz
Copy link
Owner

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

@ghost
Copy link

ghost commented Jul 6, 2014

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

@dmur
Copy link
Author

dmur commented Jul 6, 2014

@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!

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

No branches or pull requests

2 participants