iPhone SDK - How to disable the volume indicator view if the hardware buttons are pressed?

后端 未结 3 1596
猫巷女王i
猫巷女王i 2020-12-30 15:43

Is there a way to prevent the volume indicator view form showing if you press the volume up/down hardware buttons?

It\'s needed for a demo app only. So the method do

3条回答
  •  情书的邮戳
    2020-12-30 16:30

    - (void)viewDidLoad
     {
      [super viewDidLoad];
    
      //get current volume level
      oldVolume= [[MPMusicPlayerController applicationMusicPlayer] volume];
    
      //hide volume indicator         
      MPVolumeView *volumeView = [[[MPVolumeView alloc] initWithFrame:
                                 CGRectMake(0, 0, 1, 1)] autorelease];
    
      musicController=[MPMusicPlayerController applicationMusicPlayer];
      [self.view addSubview:volumeView];
      [self.view sendSubviewToBack:volumeView];
      [NSTimer scheduledTimerWithTimeInterval:0.02 target:self selector:@selector(volume) userInfo:nil repeats:YES];
    }
    
    - (void)volume
    {
      if ([musicController volume]>oldVolume || [musicController volume]

提交回复
热议问题