How do you set the hardware volume in an iPhone app?

后端 未结 2 1025
旧巷少年郎
旧巷少年郎 2020-12-28 11:01

Some iPhone applications, such as Pandora seem to directly manipulate the hardware volume and respond to physical volume button. How is this done?

AudioSessionServic

2条回答
  •  误落风尘
    2020-12-28 11:28

    They use the MPVolumeView, simple add it and it's makes the rest when the user touch it. Note: Doesn't work in iPhone Simulator. I think the release note also mentioned do not use it direct in Interface Builder.

    MPVolumeView *volumeView = [[MPVolumeView alloc] initWithFrame:CGRectMake(25, 378, 270, 30)];
    [self.view addSubview:volumeView];
    [volumeView release];
    

提交回复
热议问题