Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/97.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 尝试在第一个UIImageView上添加另一个UIImageView时发现错误_Ios_Swift_Uiimageview - Fatal编程技术网

Ios 尝试在第一个UIImageView上添加另一个UIImageView时发现错误

Ios 尝试在第一个UIImageView上添加另一个UIImageView时发现错误,ios,swift,uiimageview,Ios,Swift,Uiimageview,当用户选择一个新的图像过滤器时,我试图交叉淡入淡出的图像 因此,我在第一个视图的顶部创建了第二个ImageView,并对俯视图的alpha设置动画,以显示或隐藏底部视图 下面是我的showSecondImageView()函数: func showSecondImageView() { view.addSubview(secondImageView) secondImageView.translatesAutoresizingMaskIntoConstr

当用户选择一个新的图像过滤器时,我试图交叉淡入淡出的图像

因此,我在第一个视图的顶部创建了第二个ImageView,并对俯视图的alpha设置动画,以显示或隐藏底部视图

下面是我的showSecondImageView()函数:

    func showSecondImageView() {
        view.addSubview(secondImageView)

        secondImageView.translatesAutoresizingMaskIntoConstraints = false


        let bottomConstraint = secondImageView.topAnchor.constraintEqualToAnchor(imageView.topAnchor)
        let leftConstraint = secondImageView.leftAnchor.constraintEqualToAnchor(imageView.leftAnchor)
        let rightConstraint = secondImageView.rightAnchor.constraintEqualToAnchor(imageView.rightAnchor)
        let heightConstraint = secondImageView.heightAnchor.constraintEqualToAnchor(imageView.heightAnchor)

        NSLayoutConstraint.activateConstraints([bottomConstraint,leftConstraint,rightConstraint,heightConstraint])

        view.layoutIfNeeded()


        self.secondImageView.alpha = 0
        UIView.animateWithDuration(0.4) {
            self.secondImageView.alpha = 1.0
    }

}
输出:

    2016-02-14 23:50:17.444 Filterer[3484:344297] Unable to simultaneously satisfy constraints.
    Probably at least one of the constraints in the following list is one you don't want. 
    Try this: 
        (1) look at each constraint and try to figure out which you don't expect; 
        (2) find the code that added the unwanted constraint or constraints and fix it. 
(
    "<NSLayoutConstraint:0x7fdf58c33c80 UIImageView:0x7fdf58c30ed0.leading == UIView:0x7fdf58c22480.leading>",
    "<NSLayoutConstraint:0x7fdf58c0ff70 UIImageView:0x7fdf58c30ed0.trailing == UIView:0x7fdf58c22480.trailing>",
    "<NSLayoutConstraint:0x7fdf58c1d7d0 H:|-(0)-[UIView:0x7fdf58c22480]   (Names: '|':UIView:0x7fdf58c19270 )>",
    "<NSLayoutConstraint:0x7fdf58c1d820 H:[UIView:0x7fdf58c22480]-(0)-|   (Names: '|':UIView:0x7fdf58c19270 )>",
    "<NSLayoutConstraint:0x7fdf58f30850 H:[UIImageView:0x7fdf58f30440(600)]>",
    "<NSLayoutConstraint:0x7fdf58c5e350 UIImageView:0x7fdf58f30440.left == UIImageView:0x7fdf58c30ed0.left>",
    "<NSLayoutConstraint:0x7fdf58c79c40 UIImageView:0x7fdf58f30440.right == UIImageView:0x7fdf58c30ed0.right>",
    "<NSLayoutConstraint:0x7fdf58c32190 'UIView-Encapsulated-Layout-Width' H:[UIView:0x7fdf58c19270(375)]>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x7fdf58f30850 H:[UIImageView:0x7fdf58f30440(600)]>

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
2016-02-14 23:50:17.446 Filterer[3484:344297] Unable to simultaneously satisfy constraints.
    Probably at least one of the constraints in the following list is one you don't want. 
    Try this: 
        (1) look at each constraint and try to figure out which you don't expect; 
        (2) find the code that added the unwanted constraint or constraints and fix it. 
(
    "<_UILayoutSupportConstraint:0x7fdf58c165e0 V:[_UILayoutGuide:0x7fdf58c0fde0(0)]>",
    "<_UILayoutSupportConstraint:0x7fdf58c2eb70 _UILayoutGuide:0x7fdf58c0fde0.bottom == UIView:0x7fdf58c19270.bottom>",
    "<NSLayoutConstraint:0x7fdf58c35fc0 V:[UIButton:0x7fdf58c35d20'New Photo'(45)]>",
    "<NSLayoutConstraint:0x7fdf58c31740 V:[UIStackView:0x7fdf58c30420]-(0)-|   (Names: '|':UIView:0x7fdf58c22480 )>",
    "<NSLayoutConstraint:0x7fdf58c318a0 V:|-(0)-[UIStackView:0x7fdf58c30420]   (Names: '|':UIView:0x7fdf58c22480 )>",
    "<NSLayoutConstraint:0x7fdf58c0ffc0 V:|-(0)-[UIImageView:0x7fdf58c30ed0]   (Names: '|':UIView:0x7fdf58c19270 )>",
    "<NSLayoutConstraint:0x7fdf58c26f70 V:[UIImageView:0x7fdf58c30ed0]-(0)-[UIView:0x7fdf58c22480]>",
    "<NSLayoutConstraint:0x7fdf58c26fc0 V:[UIView:0x7fdf58c22480]-(0)-[_UILayoutGuide:0x7fdf58c0fde0]>",
    "<NSLayoutConstraint:0x7fdf58f30ab0 V:[UIImageView:0x7fdf58f30440(555)]>",
    "<NSLayoutConstraint:0x7fdf58c74640 UIImageView:0x7fdf58f30440.height == UIImageView:0x7fdf58c30ed0.height>",
    "<NSLayoutConstraint:0x7fdf58c323e0 'UISV-canvas-connection' UIStackView:0x7fdf58c30420.top == UIButton:0x7fdf58c35d20'New Photo'.top>",
    "<NSLayoutConstraint:0x7fdf58c3dd40 'UISV-canvas-connection' V:[UIButton:0x7fdf58c35d20'New Photo']-(0)-|   (Names: '|':UIStackView:0x7fdf58c30420 )>",
    "<NSLayoutConstraint:0x7fdf58c3fe60 'UIView-Encapsulated-Layout-Height' V:[UIView:0x7fdf58c19270(667)]>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x7fdf58c35fc0 V:[UIButton:0x7fdf58c35d20'New Photo'(45)]>

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
2016-02-14 23:50:17.461 Filterer[3484:344297] Unable to simultaneously satisfy constraints.
    Probably at least one of the constraints in the following list is one you don't want. 
    Try this: 
        (1) look at each constraint and try to figure out which you don't expect; 
        (2) find the code that added the unwanted constraint or constraints and fix it. 
(
    "<_UILayoutSupportConstraint:0x7fdf58c165e0 V:[_UILayoutGuide:0x7fdf58c0fde0(0)]>",
    "<_UILayoutSupportConstraint:0x7fdf58c2eb70 _UILayoutGuide:0x7fdf58c0fde0.bottom == UIView:0x7fdf58c19270.bottom>",
    "<NSLayoutConstraint:0x7fdf58c17050 V:[UIButton:0x7fdf58c16940'Edit'(45)]>",
    "<NSLayoutConstraint:0x7fdf58c31740 V:[UIStackView:0x7fdf58c30420]-(0)-|   (Names: '|':UIView:0x7fdf58c22480 )>",
    "<NSLayoutConstraint:0x7fdf58c318a0 V:|-(0)-[UIStackView:0x7fdf58c30420]   (Names: '|':UIView:0x7fdf58c22480 )>",
    "<NSLayoutConstraint:0x7fdf58c0ffc0 V:|-(0)-[UIImageView:0x7fdf58c30ed0]   (Names: '|':UIView:0x7fdf58c19270 )>",
    "<NSLayoutConstraint:0x7fdf58c26f70 V:[UIImageView:0x7fdf58c30ed0]-(0)-[UIView:0x7fdf58c22480]>",
    "<NSLayoutConstraint:0x7fdf58c26fc0 V:[UIView:0x7fdf58c22480]-(0)-[_UILayoutGuide:0x7fdf58c0fde0]>",
    "<NSLayoutConstraint:0x7fdf58f30ab0 V:[UIImageView:0x7fdf58f30440(555)]>",
    "<NSLayoutConstraint:0x7fdf58c74640 UIImageView:0x7fdf58f30440.height == UIImageView:0x7fdf58c30ed0.height>",
    "<NSLayoutConstraint:0x7fdf58c3fa40 'UISV-alignment' UIButton:0x7fdf58c35d20'New Photo'.bottom == UIButton:0x7fdf58c16940'Edit'.bottom>",
    "<NSLayoutConstraint:0x7fdf58c404d0 'UISV-alignment' UIButton:0x7fdf58c35d20'New Photo'.top == UIButton:0x7fdf58c16940'Edit'.top>",
    "<NSLayoutConstraint:0x7fdf58c323e0 'UISV-canvas-connection' UIStackView:0x7fdf58c30420.top == UIButton:0x7fdf58c35d20'New Photo'.top>",
    "<NSLayoutConstraint:0x7fdf58c3dd40 'UISV-canvas-connection' V:[UIButton:0x7fdf58c35d20'New Photo']-(0)-|   (Names: '|':UIStackView:0x7fdf58c30420 )>",
    "<NSLayoutConstraint:0x7fdf58c3fe60 'UIView-Encapsulated-Layout-Height' V:[UIView:0x7fdf58c19270(667)]>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x7fdf58c17050 V:[UIButton:0x7fdf58c16940'Edit'(45)]>

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
2016-02-14 23:50:17.444过滤器[3484:344297]无法同时满足约束。
可能下面列表中至少有一个约束是您不想要的。
试试这个:
(1) 看看每一个约束,试着找出你不期望的;
(2) 找到添加了不需要的约束的代码,然后修复它。
(
"",
"",
"",
"",
"",
"",
"",
""
)
将尝试通过打破约束进行恢复
在UIViewAlertForUnsatifiableConstraints处创建一个符号断点,以便在调试器中捕获该断点。
中列出的UIView上UIConstraintBasedLayoutDebugging类别中的方法也可能会有所帮助。
2016-02-14 23:50:17.446过滤器[3484:344297]无法同时满足约束。
可能下面列表中至少有一个约束是您不想要的。
试试这个:
(1) 看看每一个约束,试着找出你不期望的;
(2) 找到添加了不需要的约束的代码,然后修复它。
(
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
""
)
将尝试通过打破约束进行恢复
在UIViewAlertForUnsatifiableConstraints处创建一个符号断点,以便在调试器中捕获该断点。
中列出的UIView上UIConstraintBasedLayoutDebugging类别中的方法也可能会有所帮助。
2016-02-14 23:50:17.461过滤器[3484:344297]无法同时满足约束。
可能下面列表中至少有一个约束是您不想要的。
试试这个:
(1) 看看每一个约束,试着找出你不期望的;
(2) 找到添加了不需要的约束的代码,然后修复它。
(
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
""
)
将尝试通过打破约束进行恢复
在UIViewAlertForUnsatifiableConstraints处创建一个符号断点,以便在调试器中捕获该断点。
中列出的UIView上UIConstraintBasedLayoutDebugging类别中的方法也可能会有所帮助。

第一张图片是bug,第二张图片是我想要的样子,如何修复它


与您遇到的问题完全相同!我使用了上面提到的UIView.transitionWithView选项:

  UIView.transitionWithView( myImageView,
        duration: 0.4,
        options: UIViewAnimationOptions.TransitionCrossDissolve,
        animations: { self.myImageView.image = toShow},
        completion: { completed in
            //do nothing here})

其中变量“toShow”是新图像。这就避免了管理子视图的需要。

“输出显示“无法同时满足约束”-它显示的不止这些。还有很多。请显示整个消息。另外,请更准确、完整地描述视图层次结构。我刚刚添加了视图层次结构的屏幕截图和整个消息:-)在我看来,您的末日比您之前承认的要深得多。您是说在添加第二个图像视图之前从未收到过这些消息?为什么不更改图像视图的图像,然后使用
UIView.transitionWithView:
?从长远来看,这会更容易,也会为您节省一些性能。是的,我以前从未收到过这些消息。我刚刚查看了bottomMenu的约束,我发现bottomMenu的topAnchor约束到imageView。是否有可能在添加第二个imageView时更改了imageView,从而导致底部菜单的更改@马特