内部编译器错误:总线错误:10 [英] internal compiler error: Bus error: 10

查看:290
本文介绍了内部编译器错误:总线错误:10的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经写了code为甩头在屏幕上一个UIImageView动画,不过虽然语法似乎是正确的,我得到一个不起眼的内部编译器错误:总线错误:10 建设的时候。知道为什么吗?

I have written code for an animation that shakes a UIImageView on the screen, but although the syntax seems to be correct, I am getting an obscure "internal compiler error: Bus error: 10" when building. Any idea why?

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

    }
    ];
    }
    ];
}

请注意,如果我注释掉动画code最后五线,一切正常编译....什么怎么回事?

Note that if I comment out the last five lines of animation code, everything compiles fine.... What is going on?

我曾尝试切换到不同的编译器,没有工作。我确信,这里有一个 myCircle ,它曾经被称为唯一的一次是当它被声明,并且在该方法!

I have tried switching to different compilers, that didn't work. I made sure that there's just one myCircle and that the only time it ever gets referred to is when it gets declared, and in that method!

推荐答案

下面是通过递归调用函数解决问题一点解决方法。分配到 INTð由撼量,然后

Here's a little workaround that solves the problem through recursive calls to the function. Assign to int d the amount by which to shake, then

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;
        }
        ];
    }
    ];
}

这篇关于内部编译器错误:总线错误:10的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆