我有一个自定义控件,包含一排按钮,模仿标签栏。当UINavigationController
远离根视图控制器时,此控件滑出视图,并在导航到根目录时滑回。与interactivePopGestureRecognizer一起调整位置
在iOS 7中,有可以提供滑动后退手势。我正在修改我的自定义控件,以便滑动量对应于的翻译。
问题是,当用户释放触摸时,如何判断UINavigationController
是否将导航回退或反弹回原始视图?
[self.interactivePopGestureRecognizer addTarget:self action:@selector(panningBack:)];
- (void) panningBack:(UIPanGestureRecognizer *)recognizer
{
// Snipped - Code that reads the recognizer translation and adjust custom control y position
if (recognizer.state == UIGestureRecognizerStateEnded)
{
// Question: Does it go back, or does it not?
// If it goes back, slide custom control into view
// Else slide custom control out of view
}
}
如何知道导航是否会返回?当用户释放手指时? 我的想法是用导航动画动画我的自定义标签栏。 –
我最近发现了Pan Gesture识别器的一个更简单的解决方案:您可以使用velocity属性:[recognitionizer velocityInView:self.view]。如果x值为正值=向右移动=返回 – Nilz11