在更改约束常数时无法同时满足约束

时间:2015-01-03 18:23:33

标签: ios objective-c autolayout

我正在设置所有限制,如下所示: enter image description here

然后我将按钮的水平空间引用到实现文件中,以便稍后我可以更改其常量。我的目标是将其转移到保持原样的权利。我的代码是

@interface DFVDEPGCell ()
@property (strong,nonatomic)    IBOutlet UIView             *viewContainer;
@property (nonatomic, strong)   IBOutlet UILabel            *titleLabel;
@property (nonatomic, strong)   IBOutlet UILabel            *castLabel;
@property (strong, nonatomic)   IBOutlet NSLayoutConstraint *horizontalSpaceConstraint;
@property (strong, nonatomic)   NSDate                      *midNight;
@end


@implementation DFVDEPGCell   
-(void)updateCellWithInfo:(DFVDEPGShow*)show cast:(NSString*)cast title:(NSString*)title state:(BOOL)midNight {
  ..........    ..........  ..........  ..........  ..........  ..........

  BOOL isCurrentPlaying =   [[NSDate date] isBetweenDate:show.startTime andDate:show.endTime ];

  NSTimeInterval    diff    =   [show.startTime timeIntervalSinceDate:self.midNight];
  if (diff < 0 ) {
    self.horizontalSpaceConstraint.constant =   viewColumnWidth*(fabs(diff)/secondsPerMinute)/widthPerTimeslot + defaultLeadingSpace;
  }
  else {
    ;// dont shift it to the right
  }

}

当我运行应用程序时,按钮向右移动,我也正在

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. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints) 
(
    "<NSLayoutConstraint:0x7c8b6620 H:|-(428)-[UIButton:0x7c8fb7f0]   (Names: '|':UIView:0x7c8d22c0 )>",
    "<NSLayoutConstraint:0x7c8ca320 H:[UIButton:0x7c8fb7f0]-(8)-[UIView:0x7c8df260]>",
    "<NSLayoutConstraint:0x7c8f49d0 H:[UIView:0x7c8df260]-(8)-|   (Names: '|':UIView:0x7c8d22c0 )>",
    "<NSLayoutConstraint:0x7c83e270 H:|-(2)-[UIView:0x7c8d22c0]   (Names: '|':UIView:0x7c83a930 )>",
    "<NSLayoutConstraint:0x7c8c5640 H:[UIView:0x7c8d22c0]-(2)-|   (Names: '|':UIView:0x7c83a930 )>",
    "<NSAutoresizingMaskLayoutConstraint:0x7cba35d0 h=--& v=--& H:[UIView:0x7c83a930(408)]>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x7c8ca320 H:[UIButton:0x7c8fb7f0]-(8)-[UIView:0x7c8df260]>

我的想法是因为ButtonContainer1之间的水平空格设置为equal。事实上,它应该是greater than or equal(由于向右移动) 。因此,我做了一个改变,但得到了:

enter image description here

我很困惑。有没有人遇到过这种布局,并对此有任何想法。 欢迎所有评论。感谢

0 个答案:

没有答案