本文介绍了滑动返回仅适用于屏幕边缘?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的滑动返回功能有效但仅适用于屏幕边缘。如何在屏幕上的任何位置使用它?

My swipe to go back feature works but only works on the edge of the screen. How can I have it work from anywhere on the screen?

推荐答案

Apple说:

负责弹出顶视图的手势识别器控制器
离开导航堆栈。 (只读)

The gesture recognizer responsible for popping the top view controller off the navigation stack. (read-only)

@property(非原子,只读)UIGestureRecognizer
* interactivePopGestureRecognizer

@property(nonatomic, readonly) UIGestureRecognizer *interactivePopGestureRecognizer

导航控制器在其视图
上安装此手势识别器,并使用它从导航
堆栈中弹出最顶层的视图控制器。您可以使用此属性检索手势识别器
并将其与用户
界面中其他手势识别器的行为联系起来。将手势识别器绑在一起时,请确保
他们同时识别他们的手势,以确保您的
手势识别器有机会处理该事件。

The navigation controller installs this gesture recognizer on its view and uses it to pop the topmost view controller off the navigation stack. You can use this property to retrieve the gesture recognizer and tie it to the behavior of other gesture recognizers in your user interface. When tying your gesture recognizers together, make sure they recognize their gestures simultaneously to ensure that your gesture recognizers are given a chance to handle the event.

因此,库可自定义 UIPanGestureRecognizer

查看图书馆,通过使用UIPanGestureRecognizer并重新创建默认动画来实现此目的。

Check out the library SloppySwiper, which achieves this by using UIPanGestureRecognizer and by recreating the default animation.

SloppySwiper: - UINavigationController允许从屏幕上的任何位置开始向后滑动手势的委托,例如Instagram。

SloppySwiper:- UINavigationController delegate that allows swipe back gesture to be started from anywhere on the screen like instagram.

这个库的用法 。

Cocoapods : - podSloppySwiper

Cocoapods:- pod "SloppySwiper"

我测试了是ios7及以上的图书馆。它就像一个魅力。

I test this library on ios7 and above. It works like a charm.

这篇关于滑动返回仅适用于屏幕边缘?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-21 21:24