gpt4 book ai didi

iphone - 从子类调用 UIPanGestureRecognizer touchesBegan 的警告

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

在 UIPanGestureRecognizer 的自定义子类中,当我重写 touchesBegan 时:

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
[[self view].superview bringSubviewToFront:[self view]];
[super touchesBegan:touches withEvent:event];
}

super 行收到警告:

....warning: 'UIPanGestureRecognizer' may not respond to '-touchesBegan:withEvent:'
... Semantic Issue: 'UIPanGestureRecognizer' may not respond to 'touchesBegan:withEvent:'

这是为什么?

解决这个问题的最初尝试是根据 UIGestureRecognizer 子类的 UIGestureRecognizer 文档导入“UIGestureRecognizerSubclass.h”,但是当我尝试这样做时出现“没有这样的文件或目录”错误。

我已经包含了 UIKit.framework,并尝试添加

#import <UIKit/UIKit.h>

但它也不起作用。

我是不是忘记了什么?

最佳答案

这是你需要的:

#import <UIKit/UIGestureRecognizerSubclass.h>

此外,here是有关 iOS 事件编程的指南,其中包含编写手势识别器子类的说明。

关于iphone - 从子类调用 UIPanGestureRecognizer touchesBegan 的警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6651044/

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