Iphone x 失去了我的底部工具栏。如何将视图设置为安全布局区域?
Iphone x losing my bottom tool bar. How to set view into safe layout area?
我在我的应用程序上使用 wk webview 和我自己的工具栏。我已经将 webview 顶部的约束设置为 **safe layout area ** 如a中所述
https://medium.com/@hassanahmedkhan/playing-it-safe-with-safe-area-layout-guide-b3f09bdc71fe
和下图:
我的 iphone X 图像看起来像下面这样,顶部和底部有额外的白色 space,我缺少底部工具栏。 ** 请注意,黑色区域只是被遮挡,以免显示位置。这是典型的 google 地图。 **
我希望它看起来像(注意:底栏和合适的尺寸 - 没有像 iphone x 版本那样的白色 space。)
我设置网页框架(顶部)大小的代码如下所示
是否有办法将我的视图设置为安全布局 area/frame 本身?
同样,我确实按照上述 hyper link 中的描述将约束设置为安全布局区域。我需要做什么来更正 iphone x 版本? (注意:当我说正确时,我的意思是
- 去除顶部白色space
- 去除底部白色space
底部有iphone7版本的MY工具栏
谢谢。
我的工具栏出现了。我还有多余的白space,呸!如果有人对如何修复有任何想法,将不胜感激。
我将代码更改为:
// 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];
我需要从 window 框架中移除底部和顶部的高度,以便显示我的工具栏。不幸的是,就像我的第一个 post 中的图像一样 - 我在网络视图的顶部和下方仍然有多余的白色 space。现在工具栏底部有灰色 space。它看起来很糟糕,但至少可以使用。有谁知道为什么额外的白色和灰色 space?我真的很惊讶我没有收到任何答复。我错过了一些明显的东西吗?
我在我的应用程序上使用 wk webview 和我自己的工具栏。我已经将 webview 顶部的约束设置为 **safe layout area ** 如a中所述
https://medium.com/@hassanahmedkhan/playing-it-safe-with-safe-area-layout-guide-b3f09bdc71fe
和下图:
我的 iphone X 图像看起来像下面这样,顶部和底部有额外的白色 space,我缺少底部工具栏。 ** 请注意,黑色区域只是被遮挡,以免显示位置。这是典型的 google 地图。 **
我希望它看起来像(注意:底栏和合适的尺寸 - 没有像 iphone x 版本那样的白色 space。)
我设置网页框架(顶部)大小的代码如下所示
同样,我确实按照上述 hyper link 中的描述将约束设置为安全布局区域。我需要做什么来更正 iphone x 版本? (注意:当我说正确时,我的意思是
- 去除顶部白色space
- 去除底部白色space
底部有iphone7版本的MY工具栏
谢谢。
我的工具栏出现了。我还有多余的白space,呸!如果有人对如何修复有任何想法,将不胜感激。
我将代码更改为:
// 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];
我需要从 window 框架中移除底部和顶部的高度,以便显示我的工具栏。不幸的是,就像我的第一个 post 中的图像一样 - 我在网络视图的顶部和下方仍然有多余的白色 space。现在工具栏底部有灰色 space。它看起来很糟糕,但至少可以使用。有谁知道为什么额外的白色和灰色 space?我真的很惊讶我没有收到任何答复。我错过了一些明显的东西吗?