mwaterfall / MWPhotoBrowser

A simple iOS photo and video browser with grid view, captions and selections.
MIT License
8.75k stars 2.71k forks source link

reloadData MWPhotoBrowser reveals grid button in grid view #376

Open kartikthapar opened 9 years ago

kartikthapar commented 9 years ago

Fact : when grid is enabled, and user navigates to the grid view, the grid button on the toolbar doesn't show up. This is the intended behavior.

Fact: when the user clicks on the photo, the grid button is available to navigate to the grid view. This is intended behavior.

Issue: when the user has navigated to the grid view and somehow a call to the reloadData API is made, the grid button appears on the toolbar (inside the grid view). This should not be the intended behavior as grid button should be only available when the user is specifically viewing a single photo.

egfconnor commented 9 years ago

I have saw this behavior too when trying to update the selected state of views in the grid.

kartikthapar commented 9 years ago

Basically performLayout puts the main photo browser toolbar in the front. To solve this, I use the following piece of code in the reloadData API:

_toolbar.hidden = _gridController ? true : false;

This is called after performLayout has been called on the view; basically at the end of the method.

mRs- commented 9 years ago

It's not working if you are going to display the detail view of an image.

jiangyancong commented 9 years ago

I have another alternative solution. As @mRs- said, if we are going to click the grid cell to display the full image in MWPageScrollView, we need to show the tool bar to go back grid view. Here's the code in performLayout. when we add the toolbar, just insert it below gridController, it could fix the issue.

      if (_gridController) {
            [self.view insertSubview:_toolbar belowSubview:_gridController.view];
        } else {
            [self.view addSubview:_toolbar];
        }