簡體   English   中英

自動版式:NSInternalInconsistencyException與iOS11

[英]AutoLayout: NSInternalInconsistencyException with iOS11

應用程序崩潰並顯示以下日志(PFA),並且它僅在iOS 11中崩潰。

致命異常:NSInternalInconsistencyException,無法設置布局而視圖層次結構未准備好約束。

__120- [UIView(UIConstraintBasedLayout)_layoutEngine_didAddLayoutConstraint:roundingAdjustment:mutuallyExclusiveConstraints:] _ block_invoke_2

在此處輸入圖片說明

更新 :-

場景:-我在鍵盤上有一個UIToolbar,用於添加的代碼

沒有為約束准備視圖層次結構:NSLayoutConstraint:0x1c0295540 V:[UIToolbar:0x10219f550]-(0)-[_ UIRemoteKeyboardPlaceholderV‌iew: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之前運行良好。

您是否嘗試打印stacktrace來了解導致此問題的布局或視圖層次結構? 也嘗試先將視圖添加到超級視圖,然后應用約束

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM