我有一个应用程序,它在情节提要上有一个 Web 视图,它在 ASP 中加载一个注册表单,所以当键盘或选取器出现时,导航栏会隐藏,但永远不会回来,所以我无法回到最后一页。
这是我的代码:
import UIKit
class BannerViewController: UIViewController {
@IBOutlet var webView11: UIWebView!
override var preferredStatusBarStyle: UIStatusBarStyle {
return .default
}
override var prefersStatusBarHidden: Bool {
return false
}
override func viewWillAppear(_ animated: Bool) {
self.navigationItem.setHidesBackButton(false, animated: true)
self.setNeedsStatusBarAppearanceUpdate()
self.navigationController?.navigationBar.barTintColor = UIColor(red: 0, green: 0.38, blue: 0.667, alpha: 1)
self.navigationController?.navigationBar.tintColor = UIColor(red: 1, green: 1, blue: 1, alpha: 1)
var titleTextAttributes = [String : AnyObject]();
titleTextAttributes[NSFontAttributeName] = UIFont.systemFont(ofSize: 17, weight: UIFontWeightSemibold)
titleTextAttributes[NSForegroundColorAttributeName] = UIColor(red: 1, green: 1, blue: 1, alpha: 1)
self.navigationController?.navigationBar.titleTextAttributes = titleTextAttributes
}
override func viewDidLoad() {
super.viewDidLoad();
self.navigationController?.navigationBar.barStyle = .default
self.setNeedsStatusBarAppearanceUpdate()
self.navigationController?.setNavigationBarHidden(false, animated: true)
self.webView11.delegate = self;
if let unwrappedwebView11 = URL(string: "http://www.stackoverflow") {
self.webView11.loadRequest(URLRequest(url: unwrappedwebView11))
}
}
}
extension BannerViewController: UIWebViewDelegate {
}
所以,看起来我需要刷新视图或其他东西,因为我在 webView 中添加了一个后退按钮,当我单击并返回上一个视图时,然后我再次进入 webView 导航栏不再移动