如果获取耳机插入的事件

UInt32 dataSize; CFStringRef currentRoute; currentRoute = NULL; dataSize = sizeof(CFStringRef); AudioSessionInitialize(NULL, NULL, NULL, NULL); AudioSessionGetProperty(kAudioSessionProperty_AudioRoute, &dataSize, &currentRoute); if([(NSString *) currentRoute hasPrefix: @"Headphone"]) { //插入耳机后想执行的操作 }

你可能感兴趣的:(事件)