2012-01-24 2 views
0

화면에 UIImageView를 흔들어주는 애니메이션 코드를 작성했지만 올바른 구문 인 것처럼 보이지만 빌드시 애매한 "internal compiler error: Bus error: 10"이 표시됩니다. 왜 그런가? 내가 애니메이션 코드의 마지막 5 줄을 주석하는 경우, 모든 ....이 진행 이 무엇인지 잘 컴파일합니다내부 컴파일러 오류 : 버스 오류 : 10

-(IBAction)shakeCircle{ 
    int d = 3; 
    [UIView animateWithDuration:0.05 
    animations:^{myCircle.center = CGPointMake(myCircle.center.x+d, myCircle.center.y-d);} 
    completion:^(BOOL finished){ 
    [UIView animateWithDuration:0.05 
    animations:^{myCircle.center = CGPointMake(myCircle.center.x-d, myCircle.center.y+d);} 
    completion:^(BOOL finished) 
    { 
     //but if I comment from here.. 
     [UIView animateWithDuration:0.05 
     animations:^{myCircle.center = CGPointMake(myCircle.center.x+d, myCircle.center.y-d);} 
     completion:^(BOOL finished){ 
     [UIView animateWithDuration:0.05 
     animations:^{myCircle.center = CGPointMake(myCircle.center.x-d, myCircle.center.y+d);} 
     ]; 
     } 
     ]; 
     //... to here the code will build. 

    } 
    ]; 
    } 
    ]; 
} 

주?

다른 컴파일러로 전환하려고 시도했지만 작동하지 않았습니다. 나는 단지 하나의 myCircle이 있다는 것을 확인했고, 참조 될 유일한 시간은 그것이 선언 될 때 그리고 그 방법에서입니다!

+0

StackOverflow 및/또는 Google의 검색 기능이 손상 되었습니까? http://stackoverflow.com/questions/7035640/xcode-bus-error-when-compiling –

+0

미스터 황소, 나는 게시하기 전에 비슷한 질문을 한 번 보았다. 내 문제의 근본이 다르다고 나는 생각한다. – Eric

+0

질문을 편집하고 시도한 것을 사람들에게 말한 경우 도움이 될 것입니다 ... –

답변

0

다음은 함수에 대한 재귀 호출을 통해 문제를 해결할 수있는 약간의 해결책입니다. int d에 흔들림 양을 지정하십시오.

int d = 3; 
-(IBAction)shakeMyCircle{ 
    [UIView animateWithDuration:0.05 
    animations:^{myCircle.center = CGPointMake(myCircle.center.x+3, myCircle.center.y-3);} 
    completion:^(BOOL finished){ 
     [UIView animateWithDuration:0.05 
     animations:^{myCircle.center = CGPointMake(myCircle.center.x-3, myCircle.center.y+3);} 
     completion:^(BOOL finished) 
     { 
      d--; 
      if(d>0) [self shakemyCircle]; 
      if(d == 0) d = 3; 
     } 
     ]; 
    } 
    ]; 
}