gpt4 book ai didi

ios - interactivePopGestureRecognizer - 弹出或返回当前 View Controller

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:13:56 26 4
gpt4 key购买 nike

如何检测我的 interactivePopGestureRecognizer 是否已完成并将返回(弹出)到先前的 View Controller 或 shift 是否不够。然后当前 View Controller 将回到他的正常位置。

我的代码:

if ([self respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
[self.interactivePopGestureRecognizer addTarget:self action:@selector(defaultGestureAction:)];
}

- (void)defaultGestureAction:(UIGestureRecognizer *)sender {

if (sender.state == UIGestureRecognizerStateBegan || sender.state == UIGestureRecognizerStateChanged) {

} else {

//this code is fired when I touch up
//is there any way to check this action (pop or stay)?
}
}

最佳答案

我认为没有任何现成的标志可以表明手势是积极的还是消极的。

您可以通过分析平移点和速度自行尝试这样做:

- (void)defaultGestureAction:(UIScreenEdgePanGestureRecognizer *)sender
{
if (sender.state == UIGestureRecognizerStateEnded)
{
CGPoint translatedPoint = [(UIScreenEdgePanGestureRecognizer*) sender translationInView:[sender view]];
if(translatedPoint.x > self.view.bounds.size.width * 0.5f || [sender velocityInView:self.view].x > 500.0f)
{
//did trigger translation
}
else
{
//did cancel translation
}
}
}

关于ios - interactivePopGestureRecognizer - 弹出或返回当前 View Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32474426/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com