'NSInvalidArgumentException', reason: 'Unable to parse constraint format'

前端 未结 4 1356
梦如初夏
梦如初夏 2021-01-30 16:18

I have a subview that I want to keep stops during rotating screen, so I decided to put the NSLayoutConstraint type:

Trailing Space to Superview
Top Space to Supe

4条回答
  •  无人共我
    2021-01-30 16:45

    My trick is to simply declare a local variable that's just another pointer to the property, and put it in the NSDictionaryOfVariableBindings.

    @interface ViewController ()
    @property (strong) UIButton *myButton;
    @property (strong) UILabel *myLabel;
    @end
    
    ...
    
    UIButton *myButtonP = self.myButton;
    UILabel *theLabelP = self.myLabel;
    NSDictionary *viewsDictionary = NSDictionaryOfVariableBindings(myButtonP, myLabelP);
    

    The P suffix is for "pointer".

提交回复
热议问题