- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
float currPos = scroll.contentOffset.x;
BOOL movingRight = ( currPos / scroll.frame.size.width ) > 1 ? YES : NO ;
if (movingRight) {
NSLog(@"RIGHT");
[photo2 setImage:[UIImage imageNamed:@"22.jpg"]];
photo2.frame = CGRectMake(scroll.frame.size.width * 2, 0, scroll.frame.size.width, scroll.frame.size.height);
}else{
NSLog(@"LEFT");
[photo2 setImage:[UIImage imageNamed:@"33.jpg"]];
photo2.frame = CGRectMake(0, 0, scroll.frame.size.width, scroll.frame.size.height);
}
//NSLog(@"%f",currPos);
}
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{
UIImage *img = [photo1 getImage];
[photo1 setImage:[photo2 getImage]];
[self.scroll scrollRectToVisible:CGRectMake(self.scroll.frame.size.width, 0, self.scroll.frame.size.width, self.scroll.frame.size.height) animated:NO];
[photo2 setImage:img];
}