iphone - 验证 iphone 是否已连接到基座

标签 iphone ios dock mpvolumeview

当我将 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/

相关文章:

iphone - 编写通用 XML 解析器

iphone - 如何在iPhone上实现twitter登录功能

ios - Facebook 错误 Invalid_access token

objective-c - 如何从扩展坞中删除图标但保留在cmd-Tab中(Cocoa)

c# - 运行时生成的控件的 DockStyle 填充

iphone - 如何从上传的 iPhone 照片中获取正确的纬度和经度?

ios - 我希望从 iPhone 浏览的用户可以选择只上传视频或图像,而不是同时上传

iphone - CCNode的用户数据

ios - [NSTaggedPointerString 文本] : unrecognized selector sent to instance

objective-c - cocoa:知道应用程序图标在 Dock 中的位置