我UIScrollView
在UIPageViewController
. 有时UIPageViewController
没有接触,页面没有转动。
问问题
230 次
1 回答
0
I think this may help you
//*-- pagecontrol
pageControl.frame = CGRectMake(0,390,320,30);
pageControl.numberOfPages = 2;
pageControl.currentPage = 0;
[self.view addSubview:pageControl];
pageControl.backgroundColor = [UIColor darkGrayColor];
//*-- Gesture
self.pinchGestureRecognizer = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(pinchGesture:)];
self.tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleSingleTap:)];
tapGesture.numberOfTapsRequired = 1;
[imageview addGestureRecognizer:self.pinchGestureRecognizer];
[imageview addGestureRecognizer:self.tapGesture];
//delegate
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
CGFloat pageWidth = self.scrollView.frame.size.width;
float fractionalPage = self.scrollView.contentOffset.x / pageWidth;
NSInteger page = lround(fractionalPage);
self.pageControl.currentPage = page;
}
(void)changePage:(id)sender
{
//*-- Change the scroll view
CGRect frame = scrollView.frame;
frame.origin.x = frame.size.width * pageControl.currentPage;
frame.origin.y = 0;
[scrollView scrollRectToVisible:frame animated:YES];
}
写下手势动作
于 2012-12-20T13:51:14.900 回答