可能的重复:
程序访问 iPhone 音量按钮 https://stackoverflow.com/questions/772832/program-access-to-iphone-volume-buttons
是否可以在 iOS 应用程序中检测音量增大按钮的按下/释放?
您可以在应用程序中检测音量按钮按下情况,但它使用 Apple 的私有 API。由于他们不允许您在应用程序中使用他们的私有 API,因此这会直接导致您的应用程序被拒绝,因此使用此功能需要您自担风险。
In your viewDidLoad:
, 例如:
MPVolumeView *volumeView = [[MPVolumeView alloc] initWithFrame:CGRectMake(18, 340, 284, 23)];
[self.view addSubview:volumeView];
[NSNotificationCenter.defaultCenter
addObserver:self
selector:@selector(volumeDidChange:)
name:@"AVSystemController_SystemVolumeDidChangeNotification"
object:nil];
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)