【发布时间】:2019-01-06 04:18:36
【问题描述】:
我能够成功加载 pdf,但是,当加载到我的 iPhone XS Max 上时,它不会捏合和缩放。
我已经环顾了一段时间,之前回答的大多数关于此的问题都说选择“缩放以适应”,但这不是我的 Xcode 中的选项
import UIKit
import WebKit
class constantsinphysicsViewController: UIViewController
{
@IBOutlet weak var webView: WKWebView!
override func viewDidLoad()
{
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
if let pdf = Bundle.main.url(forResource: "constants", withExtension: "pdf", subdirectory: nil, localization: nil)
{
let req = NSURLRequest(url: pdf)
webView.load(req as URLRequest)
}
}
override func didReceiveMemoryWarning()
{
super.didReceiveMemoryWarning()
// Disposes of any resources that can be recreated
}
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?)
{
self.view.endEditing(true)
}
}
【问题讨论】:
-
底部函数 touchesBegan 用于在屏幕被触摸到其他任何地方时允许键盘消失。如果有帮助,我可以从这个脚本中删除它