2014-09-21 4 views
0

가속도계에서 이미지보기를 이동하는 뷰 컨트롤러를로드하려고합니다. 제목의 오류가 표시되고보기로드시 앱이 다운됩니다."countByEnumeratingWithState : objects : count :"오류

- (void)collsionWithWalls { 

    CGRect frame = self.Mover.frame; 
    frame.origin.x = self.currentPoint.x; 
    frame.origin.y = self.currentPoint.y; 

    for (UIView *image in self.wall) { 

     if (CGRectIntersectsRect(frame, image.frame)) { 

      // Compute collision angle 
      CGPoint MoverCenter = CGPointMake(frame.origin.x + (frame.size.width/2), 
               frame.origin.y + (frame.size.height/2)); 
      CGPoint imageCenter = CGPointMake(image.frame.origin.x + (image.frame.size.width/2), 
               image.frame.origin.y + (image.frame.size.height/2)); 
      CGFloat angleX = MoverCenter.x - imageCenter.x; 
      CGFloat angleY = MoverCenter.y - imageCenter.y; 

      if (abs(angleX) > abs(angleY)) { 
       _currentPoint.x = self.previousPoint.x; 
       self.MoverXVelocity = -(self.MoverXVelocity/2.0); 
      } else { 
       _currentPoint.y = self.previousPoint.y; 
       self.MoverYVelocity = -(self.MoverYVelocity/2.0); 
      } 

     } 

    } 

} 

오류는 줄에 보여줍니다 (self.wall에있는 UIView * 이미지) {에 대한

도와주세요!

+1

전체 오류 메시지를 표시하십시오. 그리고'self.wall'의 데이터 타입은 무엇입니까? – rmaddy

+0

벽은 발동기가 튀어 나오게하는 이미지입니다. 오류가 표시됩니다 : 컬렉션 표현 형식 'UIImageView *' 'countByEnumeratingWithState : objects : count :' – Yugaman

+0

에 응답하지 않을 수도 있습니다. 아마도 당신은'for (UIImage * image in self.wall.animationImages)'를 원할 것입니다. – rmaddy

답변

2

에 대한-에서 문 구문 :

for (UIView *image in self.wall) ... 

가 "... 할, 우리가 수집 self.wall에, UIView에 대한 포인터로 처리하고 image 전화 할게 각 개체에 대한"로 읽어야합니다. 당신이 말하는 것에서, self.wall는 모음집이 아닙니다. UIImageView입니다. 그것이 오류의 원인입니다. 당신은 수집이 필요한 문장을 쓰고 있지만 컬렉션을 제공하고 있지 않습니다.

그럼 왜 for 루프를 사용하고 있습니까? 반복 할 내용이 없습니다. self.wall 대신 컬렉션으로 평가되는 다른 표현식을 사용하고 싶습니까?