【发布时间】:2015-04-13 11:08:47
【问题描述】:
我对分段控件有疑问。在 iOS 8.1 中它运行完美,但在 iOS 7.1 中,我收到下面粘贴的错误,并且每次单击与该控件交互的其他分段控件时,分段控件的大小都会自动更改。 我删除了分段并再次创建,但仍然发生。 我正在添加一个约束来修改分段控制高度:
NSLayoutConstraint *constraint = [NSLayoutConstraint constraintWithItem:self.segmentedControlDistances
attribute:NSLayoutAttributeHeight
relatedBy:NSLayoutRelationEqual
toItem:nil
attribute:NSLayoutAttributeNotAnAttribute
multiplier:1
constant:50];
[self.segmentedControlDistances addConstraint:constraint];
我收到以下错误:
"2015-04-13 12:48:58.751 KMetrix[507:607] 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:0x7bece3e0 V:[UISegmentedControl:0x7beca580(50)]>",
"<NSIBPrototypingLayoutConstraint:0x7be86180 'IB auto generated at build time for view with fixed frame' H:[UISegmentedControl:0x7beca580(123)]>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x7bece3e0 V:[UISegmentedControl:0x7beca580(50)]>
Break on objc_exception_throw to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful"
我创建了 IBOutlet 和 IBAction:
- (IBAction)segmentedControlDistances:(id)sender;
@property (weak, nonatomic) IBOutlet UISegmentedControl *segmentedControlUnit, *segmentedControlSports, *segmentedControlDistances;
谢谢
【问题讨论】:
标签: ios objective-c constraints uisegmentedcontrol