ios - 使用原生 iOS 7 SDK 检测耳机插孔上的插入和拔出事件
<p><p>我正在尝试找到一种方法来检测 Native iOS SDK 中耳机插孔上的插入/拔出事件,特别是在最新版本 (iOS 7) 上。有没有办法在这个版本中做到这一点?</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>试试这个:</p>
<pre><code>[ addObserver:self selector:@selector(routeChanged:) name:AVAudioSessionRouteChangeNotification object:nil];
- (void)routeChanged:(NSNotification *)notification {
NSNumber *reason = ;
if ( == AVAudioSessionRouteChangeReasonNewDeviceAvailable) {
} else if ( == AVAudioSessionRouteChangeReasonOldDeviceUnavailable) {
}
}
</code></pre></p>
<p style="font-size: 20px;">关于ios - 使用原生 iOS 7 SDK 检测耳机插孔上的插入和拔出事件,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/23140464/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/23140464/
</a>
</p>
页:
[1]