多个名为“-setTransform:”的方法成立
-(void)rotateView:(id)sender {
CGAffineTransform rotateTransform = CGAffineTransformRotate(CGAffineTransformIdentity, M_PI);
[sender setTransform:rotateTransform];//the error is shown here
}
我收到此警告错误,显示并显示多个名为 -setTransform: 的方法。仅当我的头文件中包含 #import AVFoundation/AVFoundation.h 时,它才会显示。有什么建议吗?谢谢
-(void)rotateView:(id)sender {
CGAffineTransform rotateTransform = CGAffineTransformRotate(CGAffineTransformIdentity, M_PI);
[sender setTransform:rotateTransform];//the error is shown here
}
I am getting this caution error that shows up and says Multiple methods named -setTransform: found. It only shows up when I have #import AVFoundation/AVFoundation.h in my header file. Any suggestions? Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将
sender
转换为正确的类类型,警告就会消失:因为
sender
作为idrotateView:
code> Xcode 无法知道它是什么实际的类类型以及调用哪个方法。编辑:巧合的是,就在今天,Cocoa With Love 成名的 Matt Gallagher 发表了文章,介绍在 Objective-C 中调用
id
上的模糊方法所导致的各种问题。Cast
sender
to the proper class type and the warning should go away:As
sender
is passed torotateView:
as typeid
Xcode cannot know what actual class type it is and by that which method to call.Edit: Coincidentally just today Matt Gallagher of Cocoa With Love fame published an article about all kinds of issues caused by calling an ambiguous method on
id
in Objective-C.