检测堵塞&;使用本机iOS 7 SDK的耳机插孔发生拔出事件
我正在试图找到一种方法来检测本机iOS SDK中耳机插孔的插拔事件,特别是在最新版本(iOS 7)上。在这个版本中有没有办法做到这一点?尝试以下方法:检测堵塞&;使用本机iOS 7 SDK的耳机插孔发生拔出事件,ios,Ios,我正在试图找到一种方法来检测本机iOS SDK中耳机插孔的插拔事件,特别是在最新版本(iOS 7)上。在这个版本中有没有办法做到这一点?尝试以下方法: [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(routeChanged:) name:AVAudioSessionRouteChangeNotification object:nil]; - (void)routeChanged:(NSNot
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(routeChanged:) name:AVAudioSessionRouteChangeNotification object:nil];
- (void)routeChanged:(NSNotification *)notification {
NSNumber *reason = [notification.userInfo objectForKey:AVAudioSessionRouteChangeReasonKey];
if ([reason unsignedIntegerValue] == AVAudioSessionRouteChangeReasonNewDeviceAvailable) {
} else if ([reason unsignedIntegerValue] == AVAudioSessionRouteChangeReasonOldDeviceUnavailable) {
}
}
教程可能重复:@0xced-该页中提供的链接已断开:(我刚修好了链接。