Window for an External Display affects primary screen

别来无恙 提交于 2019-12-25 04:31:45

问题


I create a new window when there is an additional screen (up to 2). Each window shows a different content, in a different screen.

The problem is under iOS7: Creating and showing this external window makes the status bar visible in the first one, which is also the main one. Then, the system adds some space (20points) to rearrange the top bar and some views. It does not work for me, because it's a custom bar.

Why is this happening and how may I stop the system to add the status bar?

This is the offending code:

- (void) handleScreenConnectNotification:(NSNotification*)notification
{
        NSLog(@"screens=%@ _secondWindow = %@",[UIScreen screens], _secondWindow );
        if ( [[UIScreen screens] count] > 1) {
            // Associate the window with the second screen.
            // The main screen is always at index 0.
            UIScreen * secondScreen = [[UIScreen screens] objectAtIndex:1];
            CGRect screenBounds = secondScreen.bounds;

            _secondWindow = [[UIWindow alloc] initWithFrame:screenBounds];
            _secondWindow.screen = secondScreen;

            _secondWindow.hidden = NO;
        }
}

I have tried changing the _secondWindow's frame to a smaller area. Does not solve the issue.

To handle the status bar, the app is configured like this Under the app property list: View controller-based status bar appearance = YES
I added this code for each view I do not want to show the status bar:

- (BOOL)prefersStatusBarHidden
{
    return YES;
}

回答1:


Because you mentioned the "View controller-based status bar appearance" - also try setting the "Status bar is initially hidden" to true.

<key>UIStatusBarHidden</key>
<true/>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>



回答2:


To correctly handle the case you don't want the status bar initially hidden, provide a rootViewController to your second window. This rootViewController must implement -(BOOL)prefersStatusBarHidden.



来源:https://stackoverflow.com/questions/19735272/window-for-an-external-display-affects-primary-screen

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!