1

アプリが開いている間、すべてが100%機能します。ただし、アプリが閉じるとすぐに、近接センサーも停止します。私はどこでもチェックしました、そしてこれは私が持っているすべてです。

- (void)viewDidLoad
{
    [super viewDidLoad];

    //Initiates the proximity sensor
    [[UIDevice currentDevice] setProximityMonitoringEnabled:YES];
    [[UIDevice currentDevice] proximityState];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(proximityStateDidChange) name:UIDeviceProximityStateDidChangeNotification object:nil];

    //Background notification
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationDidEnterBackground) name:UIApplicationDidEnterBackgroundNotification object:nil];
}

-(void)applicationDidEnterBackground{
    NSLog(@"Entered background state.");
    [[UIDevice currentDevice] setProximityMonitoringEnabled:YES];
}

アプリを閉じると、「バックグラウンド状態になりました」と出力されます。しかし、近接センサーを監視し続けません。

4

0 に答える 0