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
static NSInteger *previousPage = 0;
in your code, which declares previousPage to be a pointer to an integer (not an integer), and initializes it to the null pointer (not the value 0 zero).
In
if(previousPage != page){ //page has changed
previousPage = page;
}
you compare the pointer value of previousPage to the integer value of page, hence the error. Simple drop the * in the declaration of previousPage.
static NSInteger previousPage = 0;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With