当我将 iPhone 连接到扩展坞时,我的应用程序会显示消息:“连接器扩展坞”。我想检测手机何时与其他设备连接并隐藏 MPVolumeView 以避免这些消息。
我像往常一样使用 MPVolumeView:
MPVolumeView *myVolume = [[MPVolumeView alloc] initWithFrame:CGRectMake(10, 435, 300, 0)];
[myVolume sizeToFit];
[self.view addSubview:myVolume];
[myVolume release];
谁能帮帮我?
最佳答案
我通过添加以下观察者来做到这一点:
NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
EAAccessoryManager *accessoryMamaner = [EAAccessoryManager sharedAccessoryManager];
[accessoryMamaner registerForLocalNotifications];
[notificationCenter addObserver: self selector: @selector (accessoryDidConnect:) name: EAAccessoryDidConnectNotification object: nil];
[notificationCenter addObserver: self selector: @selector (accessoryDidDisconnect:) name: EAAccessoryDidDisconnectNotification object: nil];
关于iphone - 验证 iphone 是否已连接到基座,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8473103/