此代码在 iOS 8.0 设备中运行良好,但在 iOS 9.0 中始终将滑块值设为 0.000...
(void) volumeUp{
MPVolumeView * volumeView = [[MPVolumeView alloc] init];
//find the volumeSlider
UISlider* volumeViewSlider = nil;
for (UIView *view in [volumeView subviews]){
if ([view.class.description isEqualToString:@"MPVolumeSlider"]){
volumeViewSlider = (UISlider*)view; // volumeViewSlider always 0.000
break;
}
}
[volumeViewSlider setValue: [volumeViewSlider value] + 0.0625 animated:YES];
[volumeViewSlider sendActionsForControlEvents:UIControlEventTouchUpInside];
}
我该如何解决?我需要每次将音量调高 0.0625。
谢谢!