rnystrom / RNGridMenu

A grid menu with elastic layout, depth of field, and realistic animation.
MIT License
1.28k stars 192 forks source link

Menu will scroll up together with table view #27

Open ishunyu opened 10 years ago

ishunyu commented 10 years ago

Hi great work on this project, I'm loving it. However there is one little bug that probably hasn't seen very often.

I have a table view controller inside a tab bar view controller. Currently, I make the call from the table view controller like this

- (IBAction)menuBarButtonPressed:(UIBarButtonItem *)sender
{
  // uncomment below to stop the table view from moving
  //  [self.tableView setContentOffset:self.tableView.contentOffset animated:NO];
  [HMTabBarViewController menuBarButtonPressedForViewController:self];
}

and then inside the tab bar view controller:

+ (void)menuBarButtonPressedForViewController:(UIViewController *)controller
{
  [(HMTabBarViewController *)[UIApplication sharedApplication].keyWindow.rootViewController menuBarButtonPressedForViewController:controller];
}

and

- (void)menuBarButtonPressedForViewController:(UIViewController *)controller
{
  RNGridMenu *gridMenu = [RNGridMenu visibleGridMenu];

  gridMenu = [[RNGridMenu alloc] initWithItems:self.gridMenuItems]; // Already have the menu items array
  [gridMenu setDelegate:self];

  [gridMenu showInViewController:controller center:CGPointMake(self.view.bounds.size.width/2.f, self.view.bounds.size.height/2.f)];
}

So this works great!

However, if I scroll the table view, and while the table view is moving, I try to open the grid menu, the grid menu will also move with the table view and it results in the grid menu either shifted up or down.

Next I tried to stop the table from moving before calling the grid menu, it works most of the time. However if the table view is in the process of refreshing(where you pull down the table and a spinner spins at the top). The grid menu will also be shifted.

grid menu bug

ishunyu commented 10 years ago

Currently working around it by doing this

- (IBAction)menuBarButtonPressed:(UIBarButtonItem *)sender
{
  if (self.tableView.contentOffset.y < 0) {
    return;
  }

  // Stop the table
  [self.tableView setContentOffset:self.tableView.contentOffset animated:NO];
  [HMTabBarViewController menuBarButtonPressedForViewController:self];
}
rlaferla commented 10 years ago

I'm seeing this same problem. The workaround works but would like to see the root problem fixed.

ishunyu commented 10 years ago

Looks like the author hasn't touched this repo in a while.

Another way is if you call

[gridMenu showInViewController:controller center:CGPointMake(self.view.bounds.size.width/2.f, self.view.bounds.size.height/2.f)];

with the parent tabbarviewcontroller instead of the children viewcontroller(in this case the tableviewcontroller) the whole screen will be blurred out and I think that might solve the problem too. Don't have time to test right now.