iOS5新增加的功能
UIPageViewController非常好用,封装了翻页功能操作,只需要给相应对象传入source就可以达到翻页的效果,但是有个问题值得注意,如果你需要在UIPageView添加控件,默认情况下UIPageViewController是不会处理此控件事件的,解决办法是重写手势处理方法,当用户点击屏幕时,可根据程序里设计的位置来决定是否需要进行翻页操作。下面的代码是在UIPageViewControllerDelegate实现类下重写gestureRecognizer方法。
//Insert the following codes into method viewDidLoad of the implement of UIPageViewControllerDelegate
for (UIGestureRecognizer *gR in self.view.gestureRecognizers) {
gR.delegate = self;
}
//Override method gestureRecognizer, return false is disabled events.
-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch {
//Touch gestures below top bar should not make the page turn.
//EDITED Check for only Tap here instead.
if ([gestureRecognizer isKindOfClass:[UITapGestureRecognizer class]]) {
CGPoint touchPoint = [touch locationInView:self.view];
if (touchPoint.y > 40) { //Which position you want disable the gesture events.
return NO;
}
}
return YES;
}
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请
点击举报。