标签:des style http color io os ar strong for
为collectionview设计了一个hearderView,而这个headerView是一个自定义的myview,在这个自定义中有一个subview,它的约束条件是设置到superview的。在Xcode 6和iOS 8的组合下运行,上述的subview完全没有按照原来设计的约束,而是以从(0,0)为原点自己重置layout。但在iOS7 + Xcode 5/6 和iOS8 + Xcode 5 的组合中是正常的。
在初始化myview的时候,添加:
self.myView.translatesAutoresizingMaskIntoConstraints = YES;
- (id)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { NSLog(@"initWithFrame"); [[NSBundle mainBundle] loadNibNamed:@"myView" owner:self options:nil]; self.myView.translatesAutoresizingMaskIntoConstraints = YES; [self addSubview:self.myView]; } return self; }
translatesAutoresizingMaskIntoConstraints:
Returns a Boolean value that indicates whether the view’s autoresizing mask is translated into constraints for the constraint-based layout system.
SWIFT
func translatesAutoresizingMaskIntoConstraints()
-> Bool
OBJECTIVE-C
- (BOOL)translatesAutoresizingMaskIntoConstraints
YES
if
the view’s autoresizing mask is translated into constraints for the constraint-based layout system, NO
otherwise.
If this is value is YES
,
the view’s superview looks at the view’s autoresizing mask, produces constraints that implement it, and adds those constraints to itself (the superview).
import
UIKit
Available in iOS 6.0 and later.
iOS Xcode为Subview设置的约束条件在iOS 8 & Xcode 6中出现异常
标签:des style http color io os ar strong for
原文地址:http://blog.csdn.net/willyang519/article/details/39557629