static NSInteger *previousPage = 0;
CGFloat pageWidth = scrollView.frame.size.width;
float fractionalPage = scrollView.contentOffset.x/pageWidth;
NSInteger page = lround(fractionalPage);
if(previousPage != page){ //page has changed
previousPage = page;
}
I’m getting the error for the previousPage != page condition
Also, the previousPage = page is giving me “incompatible integer to pointer conversion…”
You have the declaration
in your code, which declares
previousPageto be a pointer to an integer (not an integer), and initializes it to thenullpointer (not the value0zero).In
you compare the pointer value of
previousPageto the integer value ofpage, hence the error. Simple drop the*in the declaration ofpreviousPage.