화면 경계에서 스 와이프 한 경우에만 UIScrollView를 스크롤 할 수있게하려고합니다. 스 와이프 제스처 인식기를 사용하고 있습니다. 위의 코드와 여기 UISwipeGestureRecognizer에서 특정 CGPoint에 대해 UIScrollView 스크롤 사용
내 코드입니다-(void)swipeHandlerLeft:(UISwipeGestureRecognizer *)swipeRecognizer
{
CGRect screenRect = [[UIScreen mainScreen] bounds];
CGFloat screenWidth = screenRect.size.width;
point = [swipeRecognizer locationInView:self.view];
if(swipeRecognizer.direction == UISwipeGestureRecognizerDirectionLeft)
{
if (point.x > screenWidth - 10)
{
NSLog(@"Swipped Left");
_scrollView.scrollEnabled = YES;
}
else
{
_scrollView.scrollEnabled = NO;
}
}
}
-(void)swipeHandlerRight:(UISwipeGestureRecognizer *)swipeRecognizer
{
CGRect screenRect = [[UIScreen mainScreen] bounds];
CGFloat screenWidth = screenRect.size.width;
point = [swipeRecognizer locationInView:self.view];
if(swipeRecognizer.direction == UISwipeGestureRecognizerDirectionRight)
{
if (point.x < 10)
{
NSLog(@"Swipped Right");
_scrollView.scrollEnabled = YES;
}
else
{
_scrollView.scrollEnabled = NO;
}
}
}
문제가있는 ScrollView는 사용할 수 없습니다 때까지 작동,하지만이 활성화되면이 방법은 호출되지 않아요 그리고 난 그 이유는 내가 '으로 생각 내 UIView 내에서 scrollview를 추가했습니다.
어떤 도움을 주시면 감사하겠습니다.
불편을 끼쳐 드려 죄송합니다. 작은 데모 코드로 아이디어를 표현해주십시오. – Vaibhav