我有以下代码来旋转指南针。此代码适用于iPhone 6和iPhone 5上的iOS 8。
然而,在使用iOS 7.1.2的iPhone 5S上尝试此操作时,图像偏离Z轴,在旋转时看起来摇摆/浮动。
正如我所说,这不会发生在iPhone 5或6上,两者都运行iOS 8。
有人可以提供任何建议吗?
float oldRad = -manager.heading.trueHeading * M_PI / 180.0f;
float newRad = -newHeading.trueHeading * M_PI / 180.0f;
CABasicAnimation *theAnimation;
theAnimation=[CABasicAnimation animationWithKeyPath:@"transform.rotation"];
theAnimation.fromValue = [NSNumber numberWithFloat:oldRad];
theAnimation.toValue=[NSNumber numberWithFloat:newRad];
theAnimation.duration = 0.5f;
[compassimage.layer addAnimation:theAnimation forKey:@"animateMyRotation"];
compassimage.transform = CGAffineTransformMakeRotation(newRad);
答案 0 :(得分:0)
好的,我意识到这是一个AutoLayout问题。有趣的是,这个问题始于iOS 6,并向前推进到iOS 7.它似乎并没有从我看到的东西中影响iOS 8!
修复选择: - 1)添加中心x&约束 要么 2)禁用自动布局
虽然我选择了1号,但两者都产生了预期的结果!