mwaterfall / MWPhotoBrowser

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

Grid mode reloaddata #239

Closed iPermanent closed 10 years ago

iPermanent commented 10 years ago

I reload the data in the grid mode but it shows the toolbar at bottom, and I think it's a bug, as I reloaded it, the grid cannot be touch anymore, can you help me to solve it? TKS

iPermanent commented 10 years ago

ios 2014-4-4 10 34 21 Here I delete the local file and when finished, I need to reload the dataSource, the view without grid is OK but here, when i reload, the toolbar at bottom appears and the grid cannot be touch anymore, only I can touch the toolbar item.

iPermanent commented 10 years ago

ios 2014-4-4 10 37 28 ios 2014-4-4 10 37 31

ghost commented 10 years ago

Try [self reloadData]; [self showGrid:NO];

iPermanent commented 10 years ago

I am sorry but it didn't works, even if I hide the grid, the grid still show, only the toolbar at bottom hides, and when I clicked the grid to show one of them, the browser didn't respond any touch event.

ccampo commented 10 years ago

I have the same issue I call reloadData on the browser instance and it gets totally confused. It shows the grid but "thinks" that it is in single photo mode. My only workaround currently is to first load all images from my server and then start MWPhotobrowser. Dynamically changing the number of photos in the grid while the browser is loaded does not work. Easily reproducable by the demo app. It has some lines in there to show the grid, then delete a foto and then reload (last two steps are commented out, since they are meant for testing). Then the same thing happens there.....

gemmakbarlow commented 10 years ago

I was able to get the toolbar to hide by replacing the following on line 296 of MWPhotoBrowser, but the additional photo (uploaded in my case) still doesn't refresh for me:

if (hideToolbar || _gridController) {

patelmayank commented 10 years ago

ios simulator screen shot jul 31 2014 9 32 20 am ios simulator screen shot jul 31 2014 9 34 45 am

i have issues like this it appears perfect gird view after view will apear when it first Load it gives error like Pic1 ..i trying to reload Data but doesn't work i want Grid View First when MWPhotoBrowser Loded

patelmayank commented 10 years ago

@iPermanent @ccampo is there any solution for reload Data???

anthonypuppo commented 10 years ago

All you have to do to get the grid to refresh is call the collectionView's reloadData function.

if (_gridController) { _gridController.collectionView.reloadData; }

iPermanent commented 10 years ago

I decide to hide the grid select function instead of resolve the problem as the time for project is limited, thanks for you all.

Esqarrouth commented 9 years ago

I did this in swift by adding this extension from outside of the library:

extension MWPhotoBrowser {

    public override func viewWillLayoutSubviews() {
        super.viewWillLayoutSubviews()

        if let _ = valueForKey("_gridController") as? MWGridViewController {
            let leftButtonItem = editButtonItem()
            //leftButtonItem.tintColor = QorumColors.ThemeWhite
            navigationItem.leftBarButtonItem = leftButtonItem
        } else {
            navigationItem.leftBarButtonItem = nil
        }
    }

    public override func setEditing(editing: Bool, animated: Bool) {
        super.setEditing(editing, animated: animated)

        if editing {
            navigationItem.leftBarButtonItem?.title = "Delete"
            //navigationItem.leftBarButtonItem?.tintColor = QorumColors.Nickname

            displaySelectionButtons = true
            title = "Delete Photos"

            let gridController = valueForKey("_gridController") as! MWGridViewController
            gridController.selectionMode = displaySelectionButtons
            gridController.collectionView!.reloadData()
        } else {
            let nav = self.navigationController as! TempPresentVC
            let photosToDelete = nav.selectedPhotos

            let afterButtonPress = {
                //self.navigationItem.leftBarButtonItem?.tintColor = QorumColors.ThemeWhite

                self.displaySelectionButtons = false
                self.updateNavigation()

                let gridController = self.valueForKey("_gridController") as! MWGridViewController
                gridController.selectionMode = self.displaySelectionButtons
                gridController.collectionView!.reloadData()
            }

            guard photosToDelete.count > 0 else {
                afterButtonPress()
                return
            }

            let title = "Delete Photo"
            let message = "Are you sure you want to delete these photos?"
            let action = "Delete"
            let cancelAction = "Cancel"

            let alert = UIAlertController(title: title, message: message, preferredStyle: UIAlertControllerStyle.Alert)
            let declineButton = UIAlertAction(title: cancelAction, style: .Default, handler: { (action: UIAlertAction) in
                afterButtonPress()
            })
            let acceptButton = UIAlertAction(title: action, style: .Default, handler: { (action: UIAlertAction) in
                afterButtonPress()
            })
            alert.addAction(declineButton)
            alert.addAction(acceptButton)
            UIApplication.topMostController().presentVC(alert) //private lib
        }
    }
}
class TempPresentVC: UINavigationController, MWPhotoBrowserDelegate {
    var selectedPhotos = [Int]()

    func photoBrowser(photoBrowser: MWPhotoBrowser!, photoAtIndex index: UInt, selectedChanged selected: Bool) {
        if selected {
            selectedPhotos.append(index.toInt)
        } else {
            selectedPhotos.removeObject(index.toInt)
        }
    }
}
iPermanent commented 9 years ago

Sorry I am not very similar to swift yet, I just use it with some UI like tableView collectionView and so on. And the main data with network and json i still use the Objective-C.