循环通过UIImageViews查看是否有任何视图与数组中的其他视图重叠

时间:2014-09-05 19:19:37

标签: ios objective-c for-loop uiimageview

使用UIImageViews的NSArray,如何检查是否有任何视图相交。我的尝试如下。错误显示为"属性'框架'没有找到对象类型' id'"。

- (BOOL)isOverlapping:(UIImageView*)image
{
    for (int x = 0; x < objectsArray.count; x++)
    {
        if([objectsArray[x] isEqual:image])continue;
        if([objectsArray[x] isKindOfClass:[UIImageView class]])
            if(CGRectIntersectsRect(image.frame, (UIImageView)objectsArray[x].frame))
                return true;
    }
    return false;
}

1 个答案:

答案 0 :(得分:1)

尝试在括号周围包裹演员:

((UIImageView *)objectsArray[x]).frame