0

明るさ[UIScreenmainScreen].brightness = 1.0 // 0.0を使用するために、何らかのイベントが発生したことをユーザーに通知したい 代わり
に、アプリがフォアグラウンドモードの場合は正常に動作しますが、アプリケーションがバックグラウンドモードの場合、そのイベントはその時点で発生しますコードが機能していません。アプリケーションをバックグラウンドで実行できるように、ロケーションを使用しました。

アプリケーションがバックグラウンドモードのときに明るさを設定する方法を教えてください。

4

1 に答える 1

0
- (void)applicationDidEnterBackground:(UIApplication *)application
{

   // UIBackgroundTaskIdentifier *bgTask = nil;
    UIApplication  *app = [UIApplication sharedApplication];


    counterTask = [[UIApplication sharedApplication]
                   beginBackgroundTaskWithExpirationHandler:^{
                       [app endBackgroundTask:counterTask]; 
                       counterTask = UIBackgroundTaskInvalid;

                       // If you're worried about exceeding 10 minutes, handle it here  
                       theTimer=[NSTimer scheduledTimerWithTimeInterval:20
                                                                 target:self
                                                               selector:@selector(YourFunction)
                                                               userInfo:nil
                                                                repeats:YES];
                   }];

    count=0;
    theTimer=[NSTimer scheduledTimerWithTimeInterval:20
                                              target:self
                                            selector:@selector(YourFunction)
                                            userInfo:nil
                                             repeats:YES]; 

    //[super viewDidLoad];

}
于 2013-01-18T07:18:19.700 に答える