【发布时间】:2015-01-28 05:12:16
【问题描述】:
我有一个网络视图,我想填满 iDevice 的全屏。我把它放在视图的中心,设置为中心并与容器的边缘齐平。但是,当我加载应用程序时,视图比它运行的模拟 iPhone 大。我已经进行了一些搜索,有些建议自动布局,这应该是视图的中心。我发现的另一件事是通过代码设置大小。
self.webView.frame = self.view.bounds
我什至将应用程序从通用应用程序更改为 iPhone,对布局没有影响。
完整来源:
class ViewController: UIViewController {
@IBOutlet weak var webView: UIWebView!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
self.webView.frame = self.view.bounds
webView.frame = self.view.bounds
var uri = NSURL(string:"http://google.com")
var req = NSURLRequest(URL: uri)
webView.loadRequest(req)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
【问题讨论】:
-
设置 scalesPageToFit=yes
-
需要更多参考试试这个link
-
我的问题不是内容不会填满网络视图。就是网页视图不会填满设备的屏幕
-
就是这样!您可以将此添加到您的答案中,以便我选择它吗?