AutoLayout, Unable to simultaneously satisfy constraints

前端 未结 6 461
粉色の甜心
粉色の甜心 2020-12-02 08:22

Just started learning iOS AutoLayout, Interface builder very straight forward, but when I try to archive the same thing on the code

    [self.view addConstr         


        
6条回答
  •  伪装坚强ぢ
    2020-12-02 09:07

    It may be not so difficult.The message console output says that the UIButton's constraints redefined.It means just like that you put a constraint that restrict the Height and the Width of the button, but needlessly you put another restriction that the button has a Aspect Ratio.In this condition Xcode can't make sure which constraint to follow,so that you can see this debug message in console.

    There are two ways Useful for me:

    1. Analyse the constraints displayed in the console,and try to delete one or more constraint.

    2.If you are using the storyboard or Xib ,Select a constraint ->Show the Attributes Inspector -> change the priority of some Constraints.


    One more thing...

    You can follow the article of Jason Jarrett. Add a symbol breakpoint to make sure which view make the error happen.

提交回复
热议问题