gdavis/FGallery-iPhone — Issue #14: Left & Right Arrow get added to view multiple times in FGalleryViewController
Author: joeacklin
Created: 2012-01-14 18:26:20+00:00
State: open

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?