约束,在ios8 没问题,在ios7崩溃的问题,UItextField
用系统的UITextField ,加了约束,结果8上面没问题,7就崩溃了,信息如下:
Assertion failure in -[UITextField layoutSublayersOfLayer:], /SourceCache/UIKit/UIKit-2935.138/UIView.m:8794 2014-11-05 12:54:33.377 WattUp[1722:60b] Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Auto Layout still required after executing -layoutSubviews. UITextField's implementation of -layoutSubviews needs to call super.'
话不多说<解决办法,写个子类继承UITextField,然后在里面重写下面的方法,
-(instancetype)init
{
if (self = [super init]) {
}
return self;
}
- (void)setText:(NSString *)text
{
[super setText:text];
[self layoutIfNeeded];
}
-(void)setPlaceholder:(NSString *)placeholder
{
[super setPlaceholder:placeholder];
[self layoutIfNeeded];
}
-(void)layoutSubviews
{
[super layoutSubviews];
}
具体原因以后分析出来再写,