Hi i am implementing application with uiscrollview. in uiscroll view i have imageview to load imaged. i am able to scroll and move forward like 1,2,3,4,...10, but when i am in 1 st image i want to scroll in backward direction also like 1 to 10,9,8... can any one help me what i need to add in my code thank you
here is my sample code what i have implemented
- (void)loadScrollViewWithPage:(int)page {
if(page < 0 || (page >= [flashCardArry count]))
return;
FlashcardViewController *flashViewCntlObj = [flashCardViewController objectAtIndex:page%3];
//if (nil == flashViewCntlObj.view.superview)
{
CGRect frame = cardsScrollView.frame;
frame.origin.x = frame.size.width * page;
NSLog(@"%f",frame.origin.x);
frame.origin.y = 0;
flashViewCntlObj.view.frame = frame;
[cardsScrollView addSubview:flashViewCntlObj.view];
[flashViewCntlObj setflashcardObj:[flashCardArry objectAtIndex:page]];
}
}
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
{
//iscardAttended = NO;
CGFloat pageWidth = cardsScrollView.frame.size.width;
NSUInteger page = floor((self.cardsScrollView.contentOffset.x - pageWidth / 2) / pageWidth) + 1;
if(page + 1 == [flashCardArry count]){
for (NSUInteger i = 0; i < [flashCardArry count]; ++i) {
int nElements = [flashCardArry count] - i;
int n = (arc4random() % nElements) + i;
[flashCardArry exchangeObjectAtIndex:i withObjectAtIndex:n];
}
[self.cardsScrollView scrollRectToVisible:CGRectMake(self.cardsScrollView.frame.size.width * 0 , 0, self.cardsScrollView.frame.size.width, self.cardsScrollView.frame.size.height) animated:NO];
}
}
-(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{
CGFloat pageWidth = cardsScrollView.frame.size.width;
NSUInteger page = floor((self.cardsScrollView.contentOffset.x - pageWidth / 2) / pageWidth) + 1;
DBWrapper *dbWrapper = [DBWrapper sharedWrapper];
[self loadScrollViewWithPage:page - 1];
[self loadScrollViewWithPage:page];
[self loadScrollViewWithPage:page + 1];
}