Hello
Here is my issue been trying to figure it out for days now!!
I have a view: crunchViewController (with .nib file and associated appdelegate file) and I have another view called slidemenu setup as follows:
@interface SlideMenu : UIView <UIScrollViewDelegate>
In the SlideMenu I have the following properties:
UIScrollView *menuScrollView;
UIImageView *rightMenuImage;
UIImageView *leftMenuImage;
with these properties:
@property (nonatomic, retain) UIScrollView* menuScrollView;
@property (nonatomic, retain) UIImageView* rightMenuImage;
@property (nonatomic, retain) UIImageView* leftMenuImage;
In my crunchviewcontroller's .m file I call the function: - (void) viewDidLoad
which creates an instance of the slidemenu as such:
slideViewControllor = [[SlideMenu alloc] initWithFrameColorAndButtons:CGRectMake(36, 210, 250, 65) backgroundColor:[UIColor clearColor] buttons:buttonArray];
which create the slidemenuview perfectly. I can scroll left and right.
I then preform the following to create a prev and next image on either side of the scrollview right after I create the scrollview:
My setup is a follows:
in the crunchViewController.h file:
UIImageView *leftScroll;
UIImageView *rightScroll;
in the crunchViewController.m file in the function: - (void) viewDidLoad
SlideMenu *slidebtns = [[SlideMenu alloc] init];
//
leftScroll = [slidebtns initLeftImagesWithFrameColor: self.view];
//
rightScroll = [slidebtns initRightImagesWithFrameColor: self.view];
//
[slidebtns release];
which calls the functions to create the image in the SlideMenu.m file as such:
-(UIImageView *)initLeftImagesWithFrameColor: (UIView *)view {
leftMenuImage = [[UIImageView alloc] initWithFrame:CGRectMake(7, 208, 25, 68)];
leftMenuImage.image = [UIImage imageNamed:@"button_prev.png"];
leftMenuImage.opaque = YES;
//
[view addSubview:leftMenuImage];
//
return leftMenuImage;
}
I call this once for the next and once for the prev images.
So right now I create the slidemenu and the two images for next and prev as displayed as well.
Now for my issue I try and controll the next and prev images from appearing and disappearing depending on the position of the slidemenu as such:
- (void)scrollViewDidScroll

UIScrollView *)scrollView
{
if(scrollView.contentOffset.x <= 3)
{
leftMenuImage.hidden = YES;
//debug only
NSLog(@"Scroll is as far left as possible");
}
else if(scrollView.contentOffset.x >= (scrollView.contentSize.width - scrollView.frame.size.width)-3)
{
rightMenuImage.hidden = YES;
//debug only
NSLog(@"Scroll is as far right as possible");
}
else
{
leftMenuImage.hidden = NO;
rightMenuImage.hidden = NO;
//debug only
NSLog(@"Scroll somewhere in the middle");
}
}
which is where I am confused, because the scrollViewDidScroll function seems to be working properly since the NSLog are displaying the correct debug messages to me as the slidermenu is scrolled left and right, but the uiimages for the next and prev images are not being hidden (or unhidden) as it should.
Seems I am missing a reference somewhere or something and I just cant get it!
Can anyone help with this!!!