2014-09-05 21 views
0

使用UIImageViews的NSArray,如何检查是否有任何视图相交。我的尝试如下。该错误读取,“对象类型'id'”上找不到'属性'框架“。循环遍历UIImageViews以查看是否有任何视图与数组中的其他视图重叠

- (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

尝试缠绕括号中投:

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

你错过了一个指针:(UIImageView的*) – mitrenegade 2014-09-05 19:35:36

+0

谢谢!在Swift上花费的时间过多让我的头颅偏离星号。 – Pablo 2014-09-08 13:41:06