首页 > 移动平台 > 详细

约束,在ios8 没问题,在ios7崩溃的问题,UItextField

时间:2015-09-14 23:54:12      阅读:3186      评论:0      收藏:0      [点我收藏+]

用系统的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];

}

具体原因以后分析出来再写,

 

约束,在ios8 没问题,在ios7崩溃的问题,UItextField

原文:http://www.cnblogs.com/daaiwusehng/p/4808396.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!