为什么我收到警告“找到多个名为'center'的方法” [英] Why am I am getting the warning "Multiple methods named 'center' found"

查看:115
本文介绍了为什么我收到警告“找到多个名为'center'的方法”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我导入了我的助手类(#importJLHelper.h),我只会收到此警告。

I only get this warning if I import my helper class (#import "JLHelper.h").

发出警告的示例...

An example of the where the warning occurs...

[[subViews objectAtIndex:i] center].y+translation.y)];

我知道它告诉我编译器看到多个名为center的方法,但是center是在CLRegion.h的框架中声明。

I understand that it is telling me that the compiler sees more than one method named center, but center is declared in the framework in CLRegion.h.

为什么编译器在这种情况下会看到多个方法?这是一个值得关注的问题,如果是这样,我该如何追踪并解决它。

Why would the compiler see more than one method in this case? Is it a problem to be concerned about, and if so how do I track down and resolve it.

谢谢,

John

问题解决了,感谢Eric!修复后,我的代码有了更广泛的视角

NSArray *subViews = [self subviews];
UIImageView *bottomResizer;
int count = [subViews count];
for (int i =count-1; i>=0; i--) {
    if([[subViews objectAtIndex:i] tag] == 301) {
        bottomResizer = (UIImageView*)[subViews objectAtIndex:i];
        [bottomResizer setCenter:CGPointMake([bottomResizer center].x, [bottomResizer center].y+translation.y)];

    }
}


推荐答案

看起来你需要施放物品以便它知道你的意思中心...

Looks like you need to cast the object so it knows what center you mean...

[((OBJECT_TYPE*)[subViews objectAtIndex:i]) center].y+translation.y)];

其中OBJECT_TYPE是CLRegion对象

Where OBJECT_TYPE is a CLRegion Object

这篇关于为什么我收到警告“找到多个名为'center'的方法”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆