gpt4 book ai didi

ios - MPVolumeView 仅适用于 iPod

转载 作者:行者123 更新时间:2023-11-29 02:57:02 27 4
gpt4 key购买 nike

我在我的项目中添加了这样的 MPVolumeview

这是我用于 iPad 的代码。

-(void) 添加音量控制{

volumeView = [[MPVolumeView alloc] initWithFrame: CGRectMake(780, 33, 150, 40)];


NSArray *tempArray = volumeView.subviews;

for (id current in tempArray)
{
if ([current isKindOfClass:[UISlider class]])
{
UISlider *tempSlider = (UISlider *) current;
[tempSlider setMaximumTrackTintColor:[UIColor clearColor]];

CGRect rRect = tempSlider.frame;
rRect.origin.x = rRect.origin.x + 20;
tempSlider.frame = rRect;

UIImage *pMaxTrackImage;
UIImage *pMinTrackImage;
UIImage *pThumbImage;

pMaxTrackImage = [[UIImage imageNamed:@"pgbar_sound_fill_ipad"]resizableImageWithCapInsets:UIEdgeInsetsMake(0, 6, 0, 6)];
pMinTrackImage = [[UIImage imageNamed:@"pgbar_sound_bg_ipad"]resizableImageWithCapInsets:UIEdgeInsetsMake(0, 6, 0, 6)];
pThumbImage = [UIImage imageNamed:@"pgbar_sound_thumb_ipad"];

[tempSlider setMaximumTrackImage:pMaxTrackImage forState:UIControlStateNormal];
[tempSlider setMinimumTrackImage:pMinTrackImage forState:UIControlStateNormal];
[tempSlider setThumbImage:pThumbImage forState:UIControlStateNormal];
}
}

volumeView.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleTopMargin;

[self._bottomBar addSubview:volumeView];

在 iPod 中运行应用程序时音量正常,但在 iPhone 和 iPad 中不起作用。

我测试的设备是iPod5和iPhone5C。我测试的操作系统是 iOS6 和 iOS7。

我已经尝试了几乎所有可用的帮助,但没有一个对我有用。请提供一些建议/指导。

谢谢,

尼基尔.T

最佳答案

您需要设置这些值setMinimumTrackImagesetMaximumTrackImagesetThumbImage

for (UIView *sv in [volumeSlider subviews])
{
if ([sv isKindOfClass:[UISlider class]])
{
UISlider *slider = (UISlider*) sv;
[slider setMinimumTrackImage:yourImage forState:UIControlStateNormal];
[slider setMaximumTrackImage:yourImage forState:UIControlStateNormal];
[slider setThumbImage:yourImage forState:UIControlStateNormal];
}
}

关于ios - MPVolumeView 仅适用于 iPod,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23761326/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com