【发布时间】:2016-08-13 19:58:22
【问题描述】:
我的viewDidLoad 中有这个:
let childViewControllerForPosts = PostsCollectionViewController(collectionViewLayout: UICollectionViewLayout())
let cView = childViewControllerForPosts.view
self.view.backgroundColor = UIColor.redColor()
self.addChildViewController(childViewControllerForPosts)
self.view.addSubview(cView)
childViewControllerForPosts.didMoveToParentViewController(self)
NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(handleScroll(_:)), name: "cvScrolled", object: nil)
cView.widthAnchor.constraintEqualToConstant(view.frame.size.width).active = true
cView.heightAnchor.constraintEqualToConstant(view.frame.size.height).active = true
cView.topAnchor.constraintEqualToAnchor(containerForGreyAndPurple.bottomAnchor).active = true
cView.centerXAnchor.constraintEqualToAnchor(view.centerXAnchor).active = true
但是,我收到一条错误消息,指出这是一个非法约束,因为它没有共同的祖先 :(
这是错误:
...because they have no common ancestor. Does the constraint reference items in different view hierarchies? That's illegal.'
【问题讨论】:
标签: ios swift xcode7 uicontainerview