【发布时间】:2014-09-12 18:21:31
【问题描述】:
我需要在loadView 函数之外设置UIScrollView 的contentSize。
但是在尝试这样做时,我遇到了错误'UIView' does not have a member named 'contentSize'。
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
var bigRect = view.bounds
bigRect.size.width *= CGFloat(someInt)
view.contentSize = bigRect // 'UIView' does not have a member named 'contentSize'
}
override func loadView() {
view = UIScrollView(frame: UIScreen.mainScreen().bounds)
}
}
谢谢!
注意事项:
- 在控制台中,
view确实是UIScrollView的一个实例,但发送它contentSize给我同样的错误。 - 将
view替换为self.view并不能解决问题;这里没有局部变量干扰。
【问题讨论】:
-
“视图”是在代码中还是在 IB 中定义的?也许它被定义为 UIView...
标签: ios swift uiscrollview