我正在尝试实现一个非常简单的UIWebView,它使用UINavigationBar在Swift中进行导航 . 我是IOS编程的新手,花了很多时间尝试提出的解决方案,但我完全被卡住了 . 故事板看起来像:
-
查看
-
-
导航栏
-
-
-
Web View
-
当我尝试使用下面的代码段自动隐藏webview主页面上的导航栏时,导航栏只会返回到Web视图中 . 但是,当我尝试使用 self.Webview.frame = self.view.bounds
调整Web视图的大小时,它会显示重叠页面顶部的载体和电池图标 . 如果我不进行调整大小,我会得到一个隐藏UINavigationBar的空白区域 .
func webViewDidFinishLoad(webView: UIWebView) {
let currentUrl : NSString = (Webview.request?.URL!.absoluteString)!
var currentUrlString = currentUrl as String
if currentUrlString.rangeOfString("index.html") != nil {
//HIDE THE NAVIGATION BAR
myNavigationBar.hidden=true
//ADJUST THE WEBVIEW SIZE TO ACCOUNT FOR THE HIDDEN BAR
self.Webview.frame = self.view.bounds
} else {
myNavigationBar.hidden=false
Webview.frame = self.view.bounds
}
}
1 回答
使用:
代替: