2014-09-05 27 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