我正在使用下一个代码来了解何时插入设备:
- (void)applicationDidBecomeActive:(UIApplication *)application
{
//code...
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(accesoryChanged:) name:EAAccessoryDidConnectNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(accesoryChanged:) name:EAAccessoryDidDisconnectNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(accesoryChanged:) name:UIScreenDidConnectNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(accesoryChanged:) name:UIScreenDidDisconnectNotification object:nil];
EAAccessoryManager *accessoryManager = [EAAccessoryManager sharedAccessoryManager];
[accessoryManager registerForLocalNotifications];
}
- (void)accesoryChanged:(NSNotification*)note;
{
if(note.name == EAAccessoryDidConnectNotification)
{
EAAccessory* accessory = [note.userInfo objectForKey:EAAccessoryKey];
//code...
}
else if(note.name == EAAccessoryDidDisconnectNotification)
{
EAAccessory* accessory = [note.userInfo objectForKey:EAAccessoryKey];
//code...
}
}
与:
accessory.name
我可以得到设备的名称,但我找不到知道设备类型的方法(即:控制器或 HDMI 适配器)。
有什么方法可以获取这些信息吗?
提前致谢。