【发布时间】:2011-11-24 16:26:16
【问题描述】:
我使用下面的代码检查静音模式是否打开,它在 iPhone 上按预期工作,但在 iPad 上它无论如何都会返回扬声器。
CFStringRef state;
UInt32 propertySize = sizeof(CFStringRef);
AudioSessionInitialize(NULL, NULL, NULL, NULL);
AudioSessionGetProperty(kAudioSessionProperty_AudioRoute, &propertySize, &state);
if (CFStringGetLength(state) == 0) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Silent mode"
message:@"Please turn sound on"
delegate:self cancelButtonTitle:@"Ok"
otherButtonTitles:nil];
[alert show];
[alert release];
}
有什么想法可以修改它以使其通用吗?
谢谢
丹。
【问题讨论】:
标签: iphone objective-c ios ipad audio