简体   繁体   English

iPhone X失去了我的底部工具栏。 如何将视图设置为安全的布局区域?

[英]Iphone x losing my bottom tool bar. How to set view into safe layout area?

I use a wk webview and my own tool bar on my app. 我在应用程序上使用了wk webview和自己的工具栏。 I have set the constraints for the top of my webview to the **safe layout area ** as described in a https://medium.com/@hassanahmedkhan/playing-it-safe-with-safe-area-layout-guide-b3f09bdc71fe and the following image: https://medium.com/@hassanahmedkhan/playing-it-safe-with-safe-area-layout-guide中所述,我已将Web视图顶部的约束设置为**安全布局区域**。 -b3f09bdc71fe和以下图像: 在此处输入图片说明

My iphone X image looks like the following with extra white space on the top and the bottom and I am missing my bottom tool bar. 我的iphone X图像如下所示,顶部和底部都有多余的空白,并且我缺少底部的工具栏。 ** Please note the black area is simply blocked out so as not to show location. **请注意,黑色区域仅被遮挡,以免显示位置。 It is the typical google map. 这是典型的谷歌地图。 ** **

在此处输入图片说明

I want it to look like (NOTE: the bottom bar, and the proper fit - no white space as on the iphone x version.) 我希望它看起来像(注意:底部栏,并且适当合适-没有像iPhone X版本上的空白。)

在此处输入图片说明

My code that sets the size of the web frame (top portion) looks like this 我设置网络框架(顶部)大小的代码如下所示 在此处输入图片说明 IS there a way to set my view into the safe layout area/frame itself? 有没有办法让我的观点进入安全布局区域/框架本身?

Again, I do set the constraints to the safe layout area as described in the above hyper link. 同样,我确实将约束设置为安全布局区域,如以上超级链接中所述。 What do I need to do to correct for the iphone x version? 我需要怎么做才能更正iphone x版本? (NOTE: when I say correct I mean (注意:当我说正确时,我的意思是

  1. remove top white space 删除顶部空白
  2. remove bottom white space 删除底部空白
  3. have MY tool bar as show in the iphone 7 version on the bottom 底部的iPhone 7版本中显示了我的工具栏

    Thank you. 谢谢。

I got my tool bar to show up. 我出现了我的工具栏。 I still have extra white space, yuk! 我还有多余的空格,! If someone has any ideas on how to fix, it would be greatly appreciated. 如果有人对如何解决有任何想法,将不胜感激。

I changed my code to this: 我将代码更改为此:

   // Iphone x does not show tool bar and has extra padding so need to change
UIWindow *mainWindow = [[[UIApplication sharedApplication] delegate] window];

    CGFloat top = 0 ;
    CGFloat bottom = 0 ;
    bool iphoneX = NO;
    if (@available(iOS 11.0, *)) {
        top = mainWindow.safeAreaInsets.top ;
        bottom = mainWindow.safeAreaInsets.bottom ;
        if (top > 0.0) { //only have on iphonex where not zero
            iphoneX = YES;
        }
    }
    if (iphoneX)
    {
        rightSizeFrame.size.height = mainWindow.frame.size.height - top - bottom ;// notice subtracting the tool bar height instead of top and bottom did not work! - ( 1*TOOLBAR_HEIGHT) ; // need the bottom to see the tool bar not sure why
        rightSizeFrame.origin.y = 0 ; // no top whitespace
    }


    // will this set the right size aand POSITION
    [[ self webView] setFrame:rightSizeFrame] ;

    // then stick the new webView8 into the frame
    _webView8 = [[WKWebView alloc] initWithFrame:self.webView.frame
                                  configuration:configuration];

I needed the height to have both the bottom and the top removed from the window frame in order for my tool bar to show. 我需要从窗口框架中除去底部和顶部的高度,以便显示我的工具栏。 Unfortunately, like the image in my first post - I still have extra white space on top and beneath the web view. 不幸的是,就像我第一篇文章中的图像一样,我在Web视图的顶部和下方仍然有多余的空白。 And now I have gray space at the bottom of the tool bar. 现在,工具栏底部有灰色空间。 It looks terrible but at least is functional. 它看起来很糟糕,但至少可以起作用。 Does anyone have any ideas why the extra white and gray space? 有谁知道为什么会有额外的白色和灰色空间? I am actually surprised that I have received no answers. 实际上,我没有收到任何答复,我感到很惊讶。 Am I missing something obvious? 我是否缺少明显的东西?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM