Skip to content

duemunk/TDMScreenEdgePanGestureRecognizer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 

Repository files navigation

TDMScreenEdgePanGestureRecognizer

Small extension to UIScreenEdgePanGestureRecognizer to make it play nice with UIScrollViews.

How to use

TDMScreenEdgePanGestureRecognizer *screenEdgePan = [[TDMScreenEdgePanGestureRecognizer alloc] initWithTarget:self action:@selector(edgePanned:)];
screenEdgePan.edges = UIRectEdgeLeft;
[self.view addGestureRecognizer:screenEdgePan];
// Call after setup (= added to view)
[screenEdgePan requireToFailSubScrollViewsPanGestures];

Reason to use

If you have a UIScrollView and a UIScreenEdgePanGestureRecognizer, it is likely that the edgepan and the scrollview-pan conflicts. This happens when the 1) scrollview extend all (<15px approx.) the way to the edges and 2) the scrollview can bounce in the direction orthogonal to edgepans detection-edge.

Explained in code

- (void)viewDidLoad
{
  [super viewDidload];
  
  UIScrollView *scrollView = [UIScrollView new];
  self.view addSubview:scrollView];
  scrollView.frame = self.view.bounds;
  
  UIScreenEdgePanGestureRecognizer *edgePan = [[UIScreenEdgePanGestureRecognizer alloc] initWithTarget:...];
  self.view addGestureRecognizer:edgePan];
  
  // This
  edgePan.edges = UIRectLeft;
  scrollView.alwaysBounceHorizontally = YES;
}

About

Small extension to UIScreenEdgePanGestureRecognizer to make it play nice with UIScrollViews

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published