- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
int scrollCount = 0;
scrollin.text = [NSMutableString stringWithFormat:@"didScroll - %i",scrollCount];
scrollCount++;
}
Always getting didScroll – 0;
Shouldn’t it inc. as this method gets called when every scroll ends
The
scrollCountwill be initialized each time the method is called, which means it will always be 0, and therefore display 0. If you want thescrollCountto live forever in your function, you should make it static. You could do something like this:This way, the
scrollCountwill only be initialized once, and it will increment each time the method gets called.The other way, is to keep track of the
scrollCountin some sort of class variable, but that’s bad practice in my opinion, if you will only use it inside a method.