【发布时间】:2015-02-13 17:08:04
【问题描述】:
我正在尝试将 UIViewControllers 视图更改为滚动视图以供使用:
def loadView
super
scrollView = UIScrollView.alloc.initWithFrame(UIScreen.mainScreen.bounds)
self.view = scrollView
# Tried experimenting with this
# self.view.contentSize = CGSizeMake(UIScreen.mainScreen.bounds.size.width,, UIScreen.mainScreen.bounds.size.height)
self.view.backgroundColor = UIColor.whiteColor
end
然后我将子视图添加到viewDidLoad 内部的self.view,在每个子视图上使用subview.setTranslatesAutoresizingMaskIntoConstraints(false),然后使用NSLayoutConstraint.constraintsWithVisualFormat 设置约束。
约束正常工作,但是一旦我将视图更改为滚动视图,一切都会变得一团糟:
“标题”字段应与导航栏齐平,并且两个字段都应填满屏幕宽度。
红色框只是展示了子视图的宽度。
【问题讨论】:
标签: ios objective-c iphone uiscrollview rubymotion