Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/24.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 更改约束的常数时无法同时满足约束_Ios_Objective C_Autolayout - Fatal编程技术网

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

Ios 更改约束的常数时无法同时满足约束,ios,objective-c,autolayout,Ios,Objective C,Autolayout,我正在设置所有约束条件,如下所示: 然后我将按钮的水平空间引用到实现文件中,以便以后可以更改其常量。我的目标是把它移到右边,保持它的原样。我的密码是 @interface DFVDEPGCell () @property (strong,nonatomic) IBOutlet UIView *viewContainer; @property (nonatomic, strong) IBOutlet UILabel *titleLabel;

我正在设置所有约束条件,如下所示:

然后我将按钮的水平空间引用到实现文件中,以便以后可以更改其常量。我的目标是把它移到右边,保持它的原样。我的密码是

@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
  }
接口DFVDEPGCell() @属性(强,非原子)IBUIView*viewContainer; @性质(非原子,强)IBUILabel*标题标签; @属性(非原子,强)IBUILabel*castLabel; @属性(强,非原子)IBNSlayoutConstraint*horizontalSpaceConstraint; @性质(强,非原子)NSDate*午夜; @结束 @DFVDEPGCell的实现 -(void)updateCellWithInfo:(DFVDEPGShow*)show cast:(NSString*)cast title:(NSString*)title state:(BOOL)午夜{ .......... .......... .......... .......... .......... .......... BOOL isCurrentPlaying=[[NSDate-date]介于日期:show.startTime和日期:show.endTime]之间; NSTimeInterval diff=[show.startTime TimeIntervalsIncestate:self.midNight]; 如果(差异<0){ self.horizontalSpaceConstraint.constant=viewColumnWidth*(fabs(diff)/seconderminute)/widthPerTimeslot+defaultLeadingSpace; } 否则{ ;//不要把它移到右边 } }

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

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]>
无法同时满足约束。
可能下面列表中至少有一个约束是您不想要的。试着这样做:(1)看看每个约束,试着找出你不期望的约束;(2) 找到添加了不需要的约束的代码,然后修复它。(注意:如果您看到不理解的NSAutoresizingMaskLayoutConstraints,请参阅UIView属性TranslatesAutoResizingMaskToConstraints的文档)
(
"",
"",
"",
"",
"",
""
)
将尝试通过打破约束进行恢复
我的想法是因为
按钮
容器1
之间的水平空间设置为
相等
。事实上,它应该大于或等于
(由于向右移动)。因此,我做出了改变,但得到:

我很困惑。以前是否有人遇到过这种布局,并对此有任何想法。
欢迎大家在此发表意见。谢谢

单元格的总宽度是多少?你设置了444磅的间距(按钮到超级、按钮到查看、按钮到超级)。也许太多了?蓝色盒子容器也是2号还是1号?它没有任何限制吗?所以播放按钮在屏幕上移动?是的,它会在屏幕上移动。