GithubHelp home page GithubHelp logo

luugiathuy / gtscrollnavigationbar Goto Github PK

View Code? Open in Web Editor NEW
552.0 26.0 86.0 327 KB

A scrollable UINavigationBar that follows a UIScrollView

License: BSD 3-Clause "New" or "Revised" License

Ruby 0.20% Objective-C 96.41% Shell 3.39%
ios uiscrollview uinavigationbar objective-c

gtscrollnavigationbar's People

Contributors

ccraigc avatar igrandav avatar jeffphp avatar jvenegas avatar luugiathuy avatar zaully avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gtscrollnavigationbar's Issues

Feature Addition: Facebook's Status/Photo/Check-In Bar

Thank you for this project!

Would be nice to allow a sub toolbar similar to Facebook "Status Update" that scrolls first, then once fully collapsed the navigation bar collapses.

I can attach a screenshot of Facebook's implementation, but I'm assuming you have it installed since it was part of your inspiration.

Edit:
Another possibility is a toolbar at the bottom that scrolls out of view. Digg and IGN but have these bottom toolbars.

Animation should not be enable when ContenSize is smaller then the frame size

Hi,

When the ContentSize of a UIScrollView is smaller than the size of the frame the animation looks so weird because the UINavigationBar starts the animation when it should not be animated.

To test that scenario just add 4 columns in the tableView.

That can be easily fixed with this code:


- (void)handlePan:(UIPanGestureRecognizer*)gesture
{
    ...
    if ( self.scrollView.frame.size.height + (self.bounds.size.height * 2) >= self.scrollView.contentSize.height) {
        return;
    }
   ...
}

How to use with storyboards

I'm working on this small app with master detail and it uses a storyboard. Is there anyway to use this with storyboards? I don't know where to put your init code and everything I tried fails.

moreNavigationController

Great library -- works very well, generally.

When using a UITabBarController containing more than 5 viewControllers, the "More" button appears on the right. The navigationController/tableViewController/navigationBar for this item is created automatically by the SDK, and does not adhere to anything defined by GTScrollNavigationBar. Hence, you can't scroll the "More" tableView's navigationBar the way the library currently works, and the child controllers pushed from there cannot implement this functionality.

Any way around that that you're aware of?

Bug: UITableView Hidden Search Bar Causes NavBar Scrolling Flicker

Last comment, I promise, everything else is perfect.

I have a UITableView with a UISearchBar, and a UIRefreshControl. My goal is to add this GTScrollNavigationBar (with the addition of a sub menu Issue #1 ). When the search bar is visible by default, there are no issues. But when the search bar is set to be hidden by default it screws things up.

Start by modifying the example by:

  1. Modify DemoTableViewController.h
@interface DemoTableViewController : UITableViewController <UISearchBarDelegate, UISearchDisplayDelegate> {
    UISearchBar *searchBar;
    UISearchDisplayController *searchDisplayController;
}

2.Modify DemoTableViewController.m

- (void)viewDidLoad
{
    [super viewDidLoad];

    UIRefreshControl *refreshControl = [[UIRefreshControl alloc] init];
[refreshControl addTarget:self action:@selector(refresh:) forControlEvents:UIControlEventValueChanged];
    self.refreshControl = refreshControl;

    //Uncomment this line, to reproduce the issue
    //[self.tableView setContentOffset:CGPointMake(0,44) animated:YES];

    searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0, 0, 320, 44)];
    searchBar.placeholder = @"Filter Types";
    searchDisplayController = [[UISearchDisplayController alloc] initWithSearchBar:searchBar contentsController:self];
    searchDisplayController.delegate = self;
    searchDisplayController.searchResultsDataSource = self;
    searchDisplayController.searchResultsDelegate = self;
    self.tableView.tableHeaderView = searchBar;
}
- (void)refresh:(UIRefreshControl *)refreshControl {
     [refreshControl endRefreshing];
}

Run this, and everything performs as expected. Then uncomment [self.tableView setContentOffset:CGPointMake(0,44) animated:YES];. Now, tap and hold near the bottom of the screen and drag up. Instead of the the menu scrolling out of view, it will almost disappear, and then snap back to normal height. It will continue this snapping until you remove your finger from the screen.

Any help on implementing this would be great. I this its got to be in handlePan or setFrame. Ill keep playing around with it, to see if i can get it on my own.

Navigation bar won't reappear / shudders

This is easily reproducible in the example app:

  1. Carefully scroll down a few pixels then release.
  2. You'll see the nav bar correctly animate away.
  3. Now try to scroll back to the top. The nav bar won't reappear and the scrollview/nav bar shudders rapidly.

Request: Make scrollNavigationBar nullable

I think scrollingnavigationbar should be nullable for use with Swift.

@interface UINavigationController (GTScrollNavigationBarAdditions)

@property(strong, nonatomic, readonly, nullable) GTScrollNavigationBar *scrollNavigationBar;

@end


@implementation UINavigationController (GTScrollNavigationBarAdditions)

@dynamic scrollNavigationBar;

- (nullable GTScrollNavigationBar*)scrollNavigationBar
{
    return [self.navigationBar isKindOfClass:[GTScrollNavigationBar class]] ? (GTScrollNavigationBar*)self.navigationBar : nil;
}

@end

Swift example:

self.navigationController?.scrollNavigationBar?.scrollView = self.tableView

Question RE possible issue

Why do you check for (self.bounds.size.height * 2) at line 114 instead of just self.bounds.size.height? This seems to cause me issues on tableviews that are just slightly bigger then the screen, they start to scroll, and it starts to hide the nav bar, but the frame of the scrollview gets bigger (in setFrame) and the test then starts failing ,and my nav bar remains in a half hidden state until it is reset.

If I take out the multiply by two in the test it seems OK

Problems With Tableview Section headers

I've modified the sample code to add some section headers, say after every 10 rows. All works fine if I stay within a single view controller, but if I scroll down the tableview, and then drill down into a new VC, and then come back, the tableview section header is rendered in the wrong place relative to the rest of the table cells. It appears to be offset by 64 pixels, the height of the Nav bar + status bar. Scrolling the tableview immediately fixes this problem.

It appears to be related to having automaticallyAdjustEdgeInsets set - Almost as if the top inset is being applied twice - Once automatically and once by the code, adding on an extra 64 pixels.

This effectively makes this code completely broken if you want to use section headers in multiple VCs pushed onto the same NavigationController

Update POD resources

Hi, I've just recognized that the POD source are not at the current state! So please update it :)

Translucent tabbar

Hi,
I have a translucent tab bar, but i noticed that the calculations dont take this into account, its seen as the full content size, but really it should deduct the height of the bar. I believe its related to this line.
line 119:
if (self.scrollView.frame.size.height + (self.bounds.size.height * 2) >= self.scrollView.contentSize.height) {

We should check for a translucent tab bar so that we can reduce the scrollview frame size to account for this.

UIRefreshControl issue

Hi there,
I have a issue with iPhone 6 and iOS 8.0.2.

My scenario:

  • StatusBar
  • UINavigationBar
  • RefreshControl
  • UISearchBar
  • UITableView
  • UITabBar

When I try to refresh the content of the table view, before the refresh wheel completes its spin, navigation bar collapse on top. UIRefreshControl is flickery, when I drag down the view refresh control disappears, navigation bar closes itself and all the screen moves up.

Edit
This happens on iOS 7.1.2.

Any suggestion ?
Cheers

Request: Make scrollNavigationBar nullable

I think scrollingnavigationbar should be nullable for use with Swift.

`
@interface UINavigationController (GTScrollNavigationBarAdditions)

@Property(strong, nonatomic, readonly, nullable) GTScrollNavigationBar *scrollNavigationBar;

@EnD

@implementation UINavigationController (GTScrollNavigationBarAdditions)

@dynamic scrollNavigationBar;

  • (nullable GTScrollNavigationBar_)scrollNavigationBar
    {
    return [self.navigationBar isKindOfClass:[GTScrollNavigationBar class]] ? (GTScrollNavigationBar_)self.navigationBar : nil;
    }

@EnD
`

Swift example:

self.navigationController?.scrollNavigationBar?.scrollView = self.tableView

Update POD

Hey, great tool! The pod spec has not been updated with the latest fixes. It would be awesome if you could update the spec.

Navigation animation disappears in the whole app

Very nice lib, but I discovered a very rare behaviour.
I am using GTScrollNavigationBar with tableview. Sometimes when user scrolls down and a little bit up then taps on a cell (triggering push segue) push animation (and other animations like modal and pop) are being executed instantly. Any ideas?

doesn't work with titleView

If the NavigationItem.titleView have any information the scroll doesn't work. Left or Right itens works fine.

How To: Disable Show Navigation Bar Before Push/Pop?

When you are on the first uitableview, if you scroll down, the navigation bar disappears. Then you click on a row, and the navigation bar is immediately shown, and then the sub view is pushed on.

Also, happens when you scroll the pushed view down and then pop it to its parent view.

I've looked at the code, but I do not see where you are calling resetToDefaultPosition. I would have thought that it was either didSelectRowAtIndexPath OR viewDidLoad/viewWillAppear/viewDidAppear

I'm not sure if this would look funky, but would like to test out how it looks. On the Facebook app when the navigation bar is hidden on the "News Feed", and then you click a post, it does NOT show the navigation bar on the "News Feed" view. And likewise, then when you pop the "Post" view, the "News Feed" view is shown again, and the navigation bar is still hidden.

Thanks,

PS: When I'm popping the view, i'm doing so via swipe right gesture, not using the button, as it is hidden...

Subviews Layout

When the scroll view is part of more subviews in the viewController view, the subiviews are moving with the navigation bar.

Crash on resetting to default position

Hi,

I can see a lot of crashes in my Crashlytics reports, coming from
-[GTScrollNavigationBar setFrame:alpha:animated:] on the next line:
if(self.scrollView.superview).

All of this is being called from -[GTScrollNavigationBar resetToDefaultPosition:].

The crash says:
EXC_BAD_ACCESS KERN_INVALID_ADDRESS at 0x0000000c.

I am calling the resetToDefault postion in - (void)viewWillDisappear:(BOOL)animated like so:
[self.navigationController.scrollNavigationBar resetToDefaultPosition:YES];
self.navigationController.scrollNavigationBar.scrollView = nil;

As the crashes are not always reproducible, could you please help me with some hints on how to treat it, or maybe tell me what could be the problem.

Thanks

iOS 7 support

Hi,

Why did you drop support for iOS 7 on your last v0.3? Is there any API reason?

Thanks for the great work besides that ๐Ÿ‘

David

pushing a viewController crashes app

Hello,

I was using this lib now for a long time without a problem. I was using it in the ViewControllers mostly in Tabbars.

Today I wanted to normaly push a viewController but it always crashes on this line:

-(void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
//This one:
self.navigationController.scrollNavigationBar.scrollView = self.tableView;

}

I tried calling the VC so:

UINavigationController *profileNavigationController = [[UINavigationController alloc]initWithNavigationBarClass:[GTScrollNavigationBar class] toolbarClass:nil];
[profileNavigationController setViewControllers:@[viewController]];

[self.navigationController pushViewController:profileNavigationController animated:YES];

and

UINavigationController *profileNavigationController = [[UINavigationController alloc]init];
[profileNavigationController setViewControllers:@[viewController]];

[self.navigationController pushViewController:profileNavigationController animated:YES];

It doesnt throw any exception. Just a error with a pointer to a memory address... Any help would be great.

navigationBar.translucent = NO; new bug.

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];

    if (self) {

        [self setTranslucent:NO];

        [self setBarTintColor:[UIColor colorWithRed:1.00f green:0.26f blue:0.01f alpha:1.00f]];

        [self setup];

    }

    return self;
}

navigationbar and tableview have a little bug.

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.