2016-09-07 1 views
0

을 볼 돌아올 때 코어 블루투스가 복원되지 않고 나는 이제 응용 프로그램은 큰 실행 한 https://www.raywenderlich.com/52080/introduction-core-bluetooth-building-heart-rate-monitor컨트롤러에게 내가 블루투스 심장 박동 모니터에서 일하고 있어요

의 코드를 따랐다. 이 동일한 응용 프로그램 내에서 로그인 페이지 및 간단한 "About Us"페이지와 같은 몇 가지 다른 작업을 수행하는 다른 여러보기 컨트롤러가 있습니다. 내가 가진 문제는 실제 심장 박동 모니터를 포함하는 뷰 컨트롤러로 돌아올 때 모니터가 0에 위치하여 값을 업데이트하지 않는다는 것입니다.

내가이 자리에 코드 위임을 복원 있습니다

-(void)centralManager:(CBCentralManager *)central willRestoreState:(NSDictionary *)state { 

    NSLog(@"willRestoreState called"); 
    self.polarH7HRMPeripheral = [state[CBCentralManagerRestoredStatePeripheralsKey] firstItem]; 
    self.polarH7HRMPeripheral.delegate = self; 
    } 

중앙 관리자과 같이 선언 :

이 가
CBCentralManager *centralManager =[[CBCentralManager alloc] initWithDelegate:self queue:nil options:@{ CBCentralManagerOptionRestoreIdentifierKey:@"myCentralManagerIdentifier" }]; 
willRestoreState 뷰 컨트롤러에 돌아 오는 때, 나는 눈치

하지 것을 호출되고있다.

다음으로 어디를보아야 할까? 누구든지 도와 줄 수 있습니까? 미리 감사드립니다.

+1

처럼

당신은 뷰 컨트롤러에 블루투스 개체를 보유해서는 안된다. 할당 해제되지 않은 다른 클래스에서 유지 – Paulw11

답변

1

CBCentralManager의 개체가 할당 해제되면이 메서드는 CBCentralManager의 대리자 메서드이므로 작동하지 않습니다.

심장 박동을 얻을 수 있도록 CBCentralManager의 개체를 다시 초기화해야합니다. 이

self.hrCBManager = [[CBCentralManager alloc] initWithDelegate:self queue:nil]; 
관련 문제