Я хочу включить прокрутку 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;
}
}
}
Проблема с приведенным выше кодом заключается в том, что он работает до тех пор, пока прокрутка не будет включена, но как только она будет включена, эти методы не будут вызываться, и я думаю, что причина этого в том, что я добавил прокрутку внутри своего UIView.
любая помощь будет оценена.