superyeti420
1p
1 comments posted · 0 followers · following 0
16 years ago @ Simon says - Simon say's MonoTouch ... · 0 replies · +1 points
Hi Guys, great example. I made a small change to the button code, if you were pressing the buttons really quickly you could get the event to fire more than once at the last page. it was being calculated based on the current offset which caused issues, i changed it to use the page# * page width to get the correct display all the time. Include this code in the FinishedLoading method.
pageControl.ValueChanged += delegate(object sender, EventArgs e) {
var pc = (UIPageControl)sender;
double fromPage = Math.Floor((scrollView.ContentOffset.X - scrollView.Frame.Width / 2) / scrollView.Frame.Width) + 1;
var toPage = pc.CurrentPage;
var pageOffset = scrollView.Frame.Width*toPage;
Console.WriteLine("fromPage " + fromPage + " toPage " + toPage);
PointF p = new PointF(pageOffset, 0);
scrollView.SetContentOffset(p,true);
};
pageControl.ValueChanged += delegate(object sender, EventArgs e) {
var pc = (UIPageControl)sender;
double fromPage = Math.Floor((scrollView.ContentOffset.X - scrollView.Frame.Width / 2) / scrollView.Frame.Width) + 1;
var toPage = pc.CurrentPage;
var pageOffset = scrollView.Frame.Width*toPage;
Console.WriteLine("fromPage " + fromPage + " toPage " + toPage);
PointF p = new PointF(pageOffset, 0);
scrollView.SetContentOffset(p,true);
};