I need to hide the iphone screen while my application is running

I do not want the phone to sleep, so I use:

    [ [ UIApplication sharedApplication ] setIdleTimerDisabled:YES ] ;

but I need the phone to saddle on my screen so as not to lose the battery. I already saw this question. How can I omit the view in the iPhone application? but you need more details.

I am trying something like this:

to set opaqueWindow as the front-most (with a 320 x 480 black image uploaded)

[opaqueWindow makeKeyAndVisible];
[ opaqueWindow setAlpha:1.00 ] ;        
[ mainWindow setAlpha:0.10 ] ;

and try to return to the main window and set it to the foreground (selection control and some labels):

    [ opaqueWindow setAlpha:0 ] ;       
    [mainWindow makeKeyAndVisible];
    [ mainWindow setAlpha:1.00 ] ;

There can only be one key window in my application, right? therefore, when mainWindow becomes key, then opaqueWindow is not and vice versa. I create opaqueWindow and access mainWindow as follows:

    opaqueWindow = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen ] bounds]];
    opaqueView = [[UIView alloc] init];
    [opaqueWindow addSubview:opaqueView];

mainWindow = [ myApplication keyWindow ] ;

mainWindow, - , opaqueWindow .

iphone, Cocoa Touch iphone 3 .

.

!

Piesia

: , opaqueWindow mainWindow, opaqueWindow . mainWindow opaqueWindow . ! .

+3
2

, , . , . , , API ( Apple).

, , 50% . userInteractionEnabled = NO .

- (IBAction)dim:(id)sender {
    UIView *dimView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 460)];
    dimView.backgroundColor = [UIColor blackColor];
    dimView.alpha = 0.5f;
    dimView.userInteractionEnabled = NO;
    [self.view addSubview:dimView];
}

, API-:

[(id)[UIApplication sharedApplication] setBacklightLevel:1.0f];
+4

iOS 5 API:

[[UIScreen mainScreen] setBrightness:1.0];//replace 1.0 with any value...

...

+8

Source: https://habr.com/ru/post/1725876/


All Articles