GTScrollNavigationBar icon indicating copy to clipboard operation
GTScrollNavigationBar copied to clipboard

Bug: UITableView Hidden Search Bar Causes NavBar Scrolling Flicker

Open thorst opened this issue 11 years ago • 4 comments

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.

thorst avatar Jan 02 '14 20:01 thorst

I played around with a lot of different hacks. The easiest is to comment out line 137 and lines 157-166, and change alpha (line 127) to 0.0f in GTScrollNavigationBar.m.

This effectively removes the pixel for pixel on scrolling up/down. However, since I was not able to fix the actual issue, I thought this was better than nothing.

Please let me know if you are able to reproduce the issue, and if you are able to come to a real solution.

Thanks.

thorst avatar Jan 03 '14 19:01 thorst

Hi @thorst, if you want to hide the searchBar by default, adding a searchBar as a tableview's header is not a good way I think. A good way is control the frame of the seachBar in scrollViewDidScroll of your table view controller. Reference: http://stackoverflow.com/questions/4955974/uisearchbar-on-the-top-of-uitableview-which-can-hide-but-stay-close-to-uinavigat http://stackoverflow.com/questions/4870085/locking-a-uisearchbar-to-the-top-of-a-uitableview-like-game-center

What do you think?

luugiathuy avatar Jan 04 '14 03:01 luugiathuy

I guess its a matter of taste and possibly scenario. I prefer it to be in the tables header, and that seems to be the standard now, for ios7.

The game center, which these questions reference, has changed in ios7 to match the mail app.

Either way, it may be nice for this library to handle offsets.

thorst avatar Jan 06 '14 13:01 thorst

I have a regular tableHeaderView (not hidden or sticky), and it seems to cause bugs when scrolling too

thomasjoulin avatar Jan 24 '14 08:01 thomasjoulin