尝试将方法插入到 TouchBegan 中时出现错误消息

发布于 2024-08-31 01:31:06 字数 849 浏览 5 评论 0原文

我正在尝试在 TapDetectingImageView 文件中创建一个新方法,它向我发出警告,指出它无法找到该方法,即使我已在 .h 文件中声明了该方法。

当我构建它时,具体的三个警告都指向 .m 文件中的 @end 行,它们说:“类 'TapDetectingImageView' 的不完整实现;'未找到 '-functionA:' 的方法定义”; “未找到‘-functionB:’的方法定义”

我缺少什么?我是否不允许在像 TapDetectingImageView 这样的协议文件中执行此操作?

在我的 .h 文件中是:

@interface TapDetectingImageView : UIImageView <AVAudioPlayerDelegate> {

id <TapDetectingImageViewDelegate> delegate;

}

@property (nonatomic, assign) id <TapDetectingImageViewDelegate> delegate;

-(void) functionA:(NSString*)aVariable;
-(void) functionB:(NSString*)aVariable;

@end

在我的 .m 文件中是:

-(void)functionA:(NSString*)aVariable {

// do stuff in this function with aVariable

}

-(void)functionB:(NSString*)aVariable {

// do stuff in this function with aVariable

}

I am trying to create a new method within my TapDetectingImageView file and it's giving me a warning that it cannot find the method even though I have it declared in the .h file.

The specific three warnings all point to the @end line in the .m file when I build it and they say: "Incomplete implementation of class 'TapDetectingImageView' ; 'Method definition for '-functionA:' not found" ; "Method definition for '-functionB:' not found"

What am I missing? Am I not allowed to do this in a protocol file like TapDetectingImageView?

In my .h file is:

@interface TapDetectingImageView : UIImageView <AVAudioPlayerDelegate> {

id <TapDetectingImageViewDelegate> delegate;

}

@property (nonatomic, assign) id <TapDetectingImageViewDelegate> delegate;

-(void) functionA:(NSString*)aVariable;
-(void) functionB:(NSString*)aVariable;

@end

In my .m file is:

-(void)functionA:(NSString*)aVariable {

// do stuff in this function with aVariable

}

-(void)functionB:(NSString*)aVariable {

// do stuff in this function with aVariable

}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

述情 2024-09-07 01:31:06

我想通了...我必须在 .m 文件中将它们声明为私有方法才能使它们工作,然后将它们称为 [self methodName:variableIn] ...无论出于何种原因如果我在 .h 文件中声明它们,它们将不起作用。

我在导入文件之后和实现之前的 .m 文件中这样声明它们:

@interface TapDetectingImageView()
// Private Methods
-(void)functionA:(NSString *)aVariable;
-(void)functionB:(NSString *)aVariable;
@end

I figured it out... I had to declare them as private methods within the .m file in order for them to work and then call them as [self methodName:variableIn] ...for whatever reason they wouldn't work if I declared them in the .h file.

I declared them like this in the .m file right after the import files and before implementation:

@interface TapDetectingImageView()
// Private Methods
-(void)functionA:(NSString *)aVariable;
-(void)functionB:(NSString *)aVariable;
@end
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文