2012-01-24 7 views
0

UIImageViewを画面に表示するアニメーションのコードを記述しましたが、構文は正しいようですが、ビルド時にはわかりにくい "internal compiler error: Bus error: 10"が表示されています。どんな考え?内部コンパイラエラー:バスエラー: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. 

    } 
    ]; 
    } 
    ]; 
} 

注私はアニメーションコードの最後の5行をコメントアウトした場合、すべてがは何が起こっているか ....罰金コンパイルされることを?

私は別のコンパイラに切り替えようとしましたが、うまくいかなかったのです。私はちょうど1つがmyCircleであることを確かめました、そして、それが今までに参照される唯一の時間は、それが宣言されると、そのメソッドであるということです!

+0

StackOverflowやGoogleの検索機能が壊れていますか? http://stackoverflow.com/questions/7035640/xcode-bus-error-when-compiling –

+0

氏Bull、私は投稿する前に同様の質問を見て、私は私の問題の根本は異なると思う。 – 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; 
     } 
     ]; 
    } 
    ]; 
} 
関連する問題