1

iPhoneをドックに接続すると、アプリに「Conector Dock」というメッセージが表示されます。電話が他のデバイスに接続されていることを検出し、MPVolumeView を非表示にしてこれらのメッセージを回避したいと考えています。

いつものようにMPVolumeViewを使用しています:

MPVolumeView *myVolume = [[MPVolumeView alloc] initWithFrame:CGRectMake(10, 435, 300, 0)];
[myVolume sizeToFit];
[self.view addSubview:myVolume];
[myVolume release];

誰でも私を助けることができますか?

4

2 に答える 2

1

私は次のオブザーバーを追加することでそれを行いました:

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];
于 2012-02-09T18:29:35.753 に答える
0

バッテリーの状態を監視できます。

[[UIDevice currentDevice] setBatteryMonitoringEnabled:YES];

if ([[UIDevice currentDevice] batteryState] != UIDeviceBatteryStateUnplugged) {
    // if you end up in here, then you are connected to some power source
    // and you can hide your MPVolumeView
}

バッテリー状態の詳細については、Apple の UIDevice ドキュメントを参照してください。

お役に立てれば!

于 2011-12-12T11:37:52.017 に答える