为什么我收到“找不到实例方法”消息?在这里留言?
我目前正在使用此处找到的MKHorizMenu
类我试图理解为什么我收到一条未找到实例方法的消息。
我试图让应用程序以编程方式执行相当于首次加载视图控制器上的项目的操作。
我的代码:
// Actually select the item
[self.horizMenu.itemSelectedDelegate horizMenu:self.horizMenu itemSelectedAtIndex:0];
// Tap the button (change its background image etc)
NSArray *subs = [self.horizMenu subviews];
[self.horizMenu buttonTapped:(id)[subs objectAtIndex:0]]; // guilty line
警告:
警告:找不到实例方法“-buttonTapped:”(返回类型默认为“id”)
在 < code>MKHorizMenu 类该方法定义为:
-(void) buttonTapped:(id) sender
当我运行代码时,它按预期执行 - 看起来好像第一个按钮具有被窃听,并且第一个项目被选中。
为什么我会收到此警告?我如何在这里正确调用 buttonTapped
?
I'm currently using the MKHorizMenu
class found here and I'm trying to understand why I am getting an instance method not found message.
I'm trying to have the app programatically do the equivalent of tapping on of the items on the view controllers first load.
My code:
// Actually select the item
[self.horizMenu.itemSelectedDelegate horizMenu:self.horizMenu itemSelectedAtIndex:0];
// Tap the button (change its background image etc)
NSArray *subs = [self.horizMenu subviews];
[self.horizMenu buttonTapped:(id)[subs objectAtIndex:0]]; // guilty line
The warning:
warning: instance method '-buttonTapped:' not found (return type defaults to 'id')
In the MKHorizMenu
class the method is defined as:
-(void) buttonTapped:(id) sender
When I run the code, it performs as desired - it appears as if the first button has been tapped, and the first item is selected.
Why do I get this warning? How can I call buttonTapped
properly here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以通过将
buttonTapped:
的方法声明添加到类的头文件中来停止警告。You can stop the warning by adding the method declaration for
buttonTapped:
to the header file for the class.