I have a scrollView with paging. I declare it:
if(_fullPosterScroll == nil) _fullPosterScroll = [[UIScrollView alloc] initWithFrame:rc];
[_fullPosterScroll setDelegate:self];
[_fullPosterScroll setBackgroundColor:[UIColor blackColor]];
[_fullPosterScroll setCanCancelContentTouches:NO];
_fullPosterScroll.indicatorStyle = UIScrollViewIndicatorStyleWhite;
_fullPosterScroll.clipsToBounds = NO;
_fullPosterScroll.pagingEnabled = YES;
_fullPosterScroll.alwaysBounceHorizontal = NO;
_fullPosterScroll.directionalLockEnabled = YES;
And after a tap i call a method:
[_fullPosterScroll setContentOffset:CGPointMake(_selectedPosterPosition*(_fullPosterScroll.frame.size.width), 0) animated:YES];
NSLog(@"%f",_fullPosterScroll.contentOffset.y);
Why after that in Log i have for example 225.00 ?! This should be 0!
I can’t see anything wrong with the code you’ve posted, but you should check to make sure that
setContentOffsetisn’t triggering any delegate methods that are changing offset.Also, Apple have a sample project, PageControl, that does exactly what you want, so you should look at that if you want a complete example.