Why uiscrollview doesn't make visible the contentOffset change?
Hello everyone I have a problem with a uiscrollview. When I press a button to change the contentOffset scollview through a UIView animation so I have something like this:
NSLog(@"%@\n %f %f", scroll, scroll.contentOffset.x, scroll.contentOffset.y);
[UIVie开发者_运维百科w beginAnimation:@"anima" context:nil];
[UIView setAnimationDuration:0.5];
scroll.contentOffset = CGPointMake(0,index * scroll.frame.size.height;
[UIView commitAnimations];
NSLog(@"%@\n %f %f", scroll, scroll.contentOffset.x, scroll.contentOffset.y);
Making a log cotentOffSet before and after these instructions is changed and obviously the scrollview is an existing instance so it is different from nil. The problem is that the screen does not change the offset scrollview that is not moving.
I do the same thing in other parts of the code and other scrollview but it works perfectly. I also tried:
[scroll setContentOffset:CGPointMake(0, index * currentVerticalScrollView.frame.size.height) animated:YES] ;
but does not change too!
Why isn't it work?Have you ensured to invoke setContentSize:
on scroll originally, large enough to allow for the scroll offset?
If so, it may need a [scroll setNeedsDisplay]
to give it a kick!
精彩评论