iOS开发基础知识

隐藏 iPhone volume HUD

2019-01-20  本文已影响0人  永远保持一颗进取心

隐藏设备的音量的代码通常类似如下:

CGRect frame = CGRectMake(-1000, -1000, 1, 1);
 self.volumeView = [[MPVolumeView alloc] initWithFrame:frame];
 [self.view addSubview:self.volumeView];

首次进入确实有效,但是进入程序后台(background)再进入前台(foreground)的时候会失效。

在返回前台的时候 active AVAudioSession 即可修复

- (void)applicationDidBecomeActive:(UIApplication *)application {
    [[AVAudioSession sharedInstance] setActive:true error:nil];
}
上一篇 下一篇

猜你喜欢

热点阅读