首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >使用UIView 4约束关闭容器DropDownMenu中的面板

使用UIView 4约束关闭容器DropDownMenu中的面板
EN

Stack Overflow用户
提问于 2018-07-24 02:28:18
回答 1查看 53关注 0票数 0

这一问题表明,它与等级有关,我是新的斯威夫特4和谷歌地图。

从容器关闭面板时在dropView.topAnchor.constraint(equalTo: self.bottomAnchor).isActive = true上发出。

代码语言:javascript
运行
复制
override func didMoveToSuperview() {
    self.superview?.addSubview(dropView)
    self.superview?.bringSubview(toFront: dropView)
    dropView.topAnchor.constraint(equalTo: self.bottomAnchor).isActive = true // Having issue here for bottom anchor when closing the UIViewController
    dropView.centerXAnchor.constraint(equalTo: self.centerXAnchor).isActive = true
    dropView.widthAnchor.constraint(equalTo: self.widthAnchor).isActive = true
    height = dropView.heightAnchor.constraint(equalToConstant: 0)
}

这是容器关闭的代码。

代码语言:javascript
运行
复制
isHidden = !isHidden
        animateStatusBar()
        hideGrayCoverView()

        animateCenterPanelYPosition(targetPosition: 0) { (finished) in
            if finished {
                self.currentState = .collapsed
                if let mapSettings = self.mapFilterSettingsVC {
                    mapSettings.view.removeFromSuperview()
                    mapSettings.removeFromParentViewController()
                }
                self.mapFilterSettingsVC = nil
            }
        }

误差栈

在UIViewAlertForUnsatisfiableConstraints上设置一个符号断点,以便在调试器中捕捉到这一点。中列出的UIConstraintBasedLayoutDebugging类别中的UIView方法也可能有所帮助。2018-07-24 10:18:30.890527+0800 peasus3510:65686 TIC读取状态3:0x0: 1:57 2018-07-24 10:18:30.890651+0800 Pegasus3510 3510:65686 TIC读取状态3:0x0: 1:57 2018-07-24 10:18:31.017810+0800 Pegasus3510 3510:65443 Google for iOS和Google for iOS版本: 2.7.30514.0 2018-07-24 10:18:34.211751+0800 Pegasus3510 3510:65443*,终止应用程序是由于未提示的异常“NSGenericException”,原因:“不能用锚激活约束,因为它们没有共同的祖先。约束或其锚点是否引用不同视图层次结构中的项?那是非法的。“

EN

回答 1

Stack Overflow用户

发布于 2018-07-24 03:09:59

我设法通过删除mapSettings.removeFromParentViewController()来修复它。

我认为这对我来说是有意义的,因为在从容器视图(处理所有控制器的另一个UIViewController )关闭整个UIViewController时,您正在尝试删除它。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51489598

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档