在iOS 8上的MPVolumeViewanimation

在iOS 8中有一个问题或function。 当MPVolumeView显示时,它正在animation,如从0扩展到它的宽度。 我如何解决这个问题? iOS 7上没有这样的问题。

删除此行为的一种可能的方法是inheritanceMPVolumeView并在[super layoutSubviews]之后执行一些额外的工作。

 - (void)layoutSubviews { [super layoutSubviews]; [self cg_recursiveRemoveAnimationsOnView:self]; } - (void)cg_recursiveRemoveAnimationsOnView:(UIView *)view { [view.layer removeAllAnimations]; for (UIView *subview in view.subviews) { [self cg_recursiveRemoveAnimationsOnView:subview]; } } 

这将删除所有插入的animation。 所以要确定这是你想要的,因为这是相当的矫枉过正。 也可以删除positionboundsanimation(请参阅removeAnimationForKey:

我确认这个问题在iOS 8中仍然存在。在上面的注释之一(重写volumeSliderRectForBounds)中,Anastasia提供的解决方法似乎可行,但只有当路由button不存在时。 当它出现时,滑块重叠在pathbutton上,不能再按下。

我对她的解决scheme做了一个简单的修改,也许有人可以使用它作为解决方法,直到苹果修复或提供更好的解决scheme。

 - (CGRect)volumeSliderRectForBounds:(CGRect)bounds { if (self.showsRouteButton) { NSInteger spacer = 10; /* Space between Route button and Volume slider */ CGRect routeButtonRect = [self routeButtonRectForBounds:bounds]; bounds.size.width -= (routeButtonRect.size.width + spacer); } return bounds; } 

我不喜欢对间隔符值进行硬编码,但是我找不到如何dynamic计算它。