このコードは機能します (アニメーション付きの if ステートメント):
// works
if (_camOrientation == UIDeviceOrientationPortrait) {
[UIView animateWithDuration:0.5f animations:^(void){
[_distanceView setTransform:CGAffineTransformMakeRotation(degreesToRadian(0.0))];
}];
} else if (_camOrientation == UIDeviceOrientationLandscapeLeft) {
[UIView animateWithDuration:0.5f animations:^(void){
[_distanceView setTransform:CGAffineTransformMakeRotation(degreesToRadian(90.0))];
}];
}
これも機能します (アニメーションなしの switch-statement):
// works
switch (_camOrientation) {
case UIDeviceOrientationPortrait:
[_distanceView setTransform:CGAffineTransformMakeRotation(degreesToRadian(0.0))];
break;
case UIDeviceOrientationLandscapeLeft:
[_distanceView setTransform:CGAffineTransformMakeRotation(degreesToRadian(90.0))];
break;
default:
break;
}
これはクラッシュします (アニメーション付きの switch-statement):
// crashes
switch (_camOrientation) {
case UIDeviceOrientationPortrait:
[UIView animateWithDuration:0.5f animations:^(void){
[_distanceView setTransform:CGAffineTransformMakeRotation(degreesToRadian(0.0))];
}];
break;
case UIDeviceOrientationLandscapeLeft:
[UIView animateWithDuration:0.5f animations:^(void){
[_distanceView setTransform:CGAffineTransformMakeRotation(degreesToRadian(90.0))];
}];
break;
default:
break;
}
switch ステートメントでアニメーション ブロックを使用できないのはなぜですか?!?