2011-12-12 3 views
1

iphone을 도크에 연결하면 내 앱에 "Conector dock"메시지가 표시됩니다. 전화가 다른 장치와 연결되어있을 때이를 감지하고 해당 메시지를 피하기 위해 MPVolumeView를 숨기고 싶습니다.iphone이 Dock에 연결되었는지 확인

이 나는 ​​평소와 같이 MPVolumeView을 사용하고 있습니다 :

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

이 사람이 나를 도울 수 있을까요?

답변

0

나는 따라 관찰자를 추가하여 해당했다. 나는이 행동을 원하지 않는다.
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's UIDevice documentation에서 확인할 수 있습니다.

희망이 도움이됩니다. 나는 휴대폰을 컴퓨터에 연결하면이 경우

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]; 
+0

이이 MPVolumeView 숨겨진 유지가 발생합니다 – flopes

+0

질문이 혼란 스럽습니다. 나는 당신이하려고하는 것이 확실하지 않습니다. –

+0

도크는 몇 가지 추가 기능을 제공하기 위해 휴대 전화를 연결할 수있는 외부 장치입니다. 외부 스피커로 음악을 재생하고, 전화를 충전하고, 다른 기능을 사용할 수있는 부두가 있습니다. 보통 usb 케이블없이 휴대 전화를 직접 꽂습니다. – flopes