1.设置scrollview没有反弹效果

scrollview.bounces = NO;


2.在scrollview上添加很多控制器的view,在滑动到最左侧(第一个)view时,再右滑不在是反弹效果,而是调用某个方法时:

步骤1:重写scrollview类,在scrollview类里有个

-(BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer

方法


例如

-(BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer

{

if ([gestureRecognizer isKindOfClass:[UIPanGestureRecognizer class]]) {

UIPanGestureRecognizer *pan = (UIPanGestureRecognizer *)gestureRecognizer;

CGPoint point = [pan translationInView:self];

if (point.x>0) {

//向右拖动

self.isRightSlide = YES;

}else

{

//不是向右拖动

self.isRightSlide = NO;

}

}

return YES;

}


步骤2:在添加scrollview的主控制器里实现scrollview的代理方法

#pragma mark -scrollView代理方法

- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView;

{

//判断左侧第一个view和scrollview是向右滑动

if (scrollView.contentOffset.x == 0 && myscrollView.isRightSlide == YES) {

//调用第一个视图右滑时要调用的方法

[self someFunction];

}

}