【发布时间】:2015-12-26 00:50:58
【问题描述】:
我正在尝试在容器视图中设置视图。由于swipeView 内的视图有多个不同的控制器,因此必须这样做。
@IBOutlet weak var containerView: ContainerView!
override func viewDidLoad() {
super.viewDidLoad()
//Some other stuff
//Create new swipeView
var swipeView = MDCSwipeToChooseView(frame: containerView.frame, options: options)
//Add the view from the controller to the swipeView
swipeView.addSubview(containerViewController.view)
//Add the swipeView to the main view
self.view.addSubview(swipeView)
我最终得到了这个
白色区域是应该继承containerView 大小的视图。 containerView 是背景中的粉红色,并且显示正确。我注意到containerView.frame 从情节提要返回组件的大小,参见图 2。通过调用 containerView.frame 获得的框架是调整视图大小以满足所有约束之前的框架。如何获得正确的值?
【问题讨论】:
标签: ios swift uiview uicontainerview