IPhone : Scrollview with left and right arrows in IOS

on Tuesday, March 31, 2015

I have a scrollview with set of images with left and right button. I have implement the left button action for moving the image left side using this code



if ( scroll.contentOffset.x <= scroll.frame.size.width ) {
CGRect frame;
frame.origin.x = scroll.contentOffset.x + scroll.frame.size.width;
frame.origin.y = 0;
frame.size = scroll.frame.size;
//NSLog(@"%f %f %f", frame.origin.y ,scroll.frame.size.width, frame.origin.x);
[scroll scrollRectToVisible:frame animated:YES];
}


its working perfectly


same i implement the functionality for right button action not working properly what i am doing wrong the code is below



if ( scroll.contentOffset.y <= scroll.frame.size.width ) {
CGRect frame;
frame.origin.x = 0;
frame.origin.y = scroll.frame.size.width + scroll.contentOffset.y;
frame.size = scroll.frame.size;
NSLog(@"%f %f %f", frame.origin.y ,scroll.frame.size.width, frame.origin.x);
[scroll scrollRectToVisible:frame animated:YES];
}

0 comments:

Post a Comment