gdavis / FGallery-iPhone

Objective-C based gallery for iPhones
583 stars 144 forks source link

Left & Right Arrow get added to view multiple times in FGalleryViewController #14

Closed joeacklin closed 12 years ago

joeacklin commented 12 years ago

Occasionally the FGalleryViewController will add additional left and right arrows into the toolbar each time the view controller is navigated back to ([[self navigationController] popViewControllerAnimated:YES];)

I have looked at the code where the left and right arrows are loading into the view and it does not make sense because the loadView method is not called when the popViewControllerAnimated is called. I have also added:

if([[_toolbar items] count] == 0)
    {
        UIImage *leftIcon = [UIImage imageNamed:@"photo-gallery-left.png"];
        UIImage *rightIcon = [UIImage imageNamed:@"photo-gallery-right.png"];
        _nextButton = [[UIBarButtonItem alloc] initWithImage:rightIcon style:UIBarButtonItemStylePlain target:self action:@selector(next)];
        _prevButton = [[UIBarButtonItem alloc] initWithImage:leftIcon style:UIBarButtonItemStylePlain target:self action:@selector(previous)];

        // add prev next to front of the array
        [_barItems insertObject:_nextButton atIndex:0];
        [_barItems insertObject:_prevButton atIndex:0];

        _prevNextButtonSize = leftIcon.size.width;

        // set buttons on the toolbar.
        [_toolbar setItems:_barItems animated:NO];
    }

which should make certain that only the 2 arrow buttons get added, this also does not fix the issue. Any ideas?