ios 7.1的高分段控制

时间:2015-04-07 16:44:26

标签: ios objective-c xcode uisegmentedcontrol

我使用此代码更改分段控制高度。它适用于8.0和最新版本,但不像7.1那样低。你还知道改变它的其他方法吗?谢谢!

NSLayoutConstraint *constraint = [NSLayoutConstraint constraintWithItem:segmentedControlShortcuts
                                                              attribute:NSLayoutAttributeHeight
                                                              relatedBy:NSLayoutRelationEqual
                                                                 toItem:nil
                                                              attribute:NSLayoutAttributeNotAnAttribute
                                                             multiplier:1
                                                               constant:50];

这是我在7.1中收到的错误:

" 2015-04-09 12:10:06.626 KMetrix [546:607]无法同时满足约束条件。     可能至少以下列表中的一个约束是您不想要的约束。试试这个:(1)看看每个约束,并试着找出你不期望的东西; (2)找到添加了不需要的约束或约束的代码并修复它。 (注意:如果您正在查看您不了解的NSAutoresizingMaskLayoutConstraints,请参阅UIView属性的文档translatesAutoresizingMaskIntoConstraints) (     "&#34 ;,     "" )

将尝试通过违反约束来恢复

中断objc_exception_throw以在调试器中捕获它。 在列出的UIView上的UIConstraintBasedLayoutDebugging类别中的方法也可能有用。"

1 个答案:

答案 0 :(得分:0)

试试这个。在iOS7和iOS中都经过测试iOS8 -

NSLayoutConstraint *constraint = [NSLayoutConstraint constraintWithItem:self.mySegmentCtrl
                                                              attribute:NSLayoutAttributeHeight
                                                              relatedBy:NSLayoutRelationEqual
                                                                 toItem:nil
                                                              attribute:NSLayoutAttributeNotAnAttribute
                                                             multiplier:1
                                                               constant:50];
[self.mySegmentCtrl addConstraint:constraint];

检查它在iOS7和iOS中都有效的截图iOS8 -

enter image description here

enter image description here