应用程序在以下日志(P.F.A)中崩溃,这是它在iOS 11中唯一的崩溃。
致命异常: NSInternalInconsistencyException,不可能设置视图层次结构没有为约束做好准备的布局。 __120-UIView(UIConstraintBasedLayout) _layoutEngine_didAddLayoutConstraint:roundingAdjustment:mutuallyExclusiveConstraints:_block_invoke_2

更新:-
场景:-我在键盘上有一个UIToolbar,用于添加
视图层次结构没有准备好约束: NSLayoutConstraint:0x1c0295540 V:UIToolbar:0x10219f550-(0)-UIRemoteKeyboardPlaceholderView:0x10219fab0
#pragma mark KeyBoard Related Function
-(void)createInputAccessoryView:(NSInteger )tagNumber
{
inputAccessoryView = [[UIToolbar alloc]init];
[inputAccessoryView setBackgroundColor:kKYBOARDCOLOR];
[inputAccessoryView sizeToFit];
[inputAccessoryView setHidden:NO];
//Use this to put space in between your toolbox buttons
UIBarButtonItem *barSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace
target:nil
action:nil];
UIBarButtonItem *barBtnDone = [[UIBarButtonItem alloc] initWithTitle:@"Done"
style:UIBarButtonItemStyleDone
target:self action:@selector(actnResignKeyboard)];
NSArray *barItems;
barItems = [NSArray arrayWithObjects:barSpace,barBtnDone, nil];
[inputAccessoryView setItems:barItems animated:YES];
}键盘的出现和消失会导致崩溃,但当我删除UIToolbar时,所有的东西都会正常工作。
注意:-此代码在iOS 11.之前运行良好。
发布于 2017-10-11 11:13:30
您是否尝试打印堆栈跟踪以了解导致这种情况的布局或视图层次结构?还尝试先将视图添加到superview,然后应用约束
https://stackoverflow.com/questions/46682470
复制相似问题