gpt4 book ai didi

ios - 仅警告一次 : UITableView was told to layout its visible cells and other contents without being in the view hierarchy?

转载 作者:行者123 更新时间:2023-12-04 12:23:40 29 4
gpt4 key购买 nike

我在 viewController 上添加了 tableView。
当我打开此屏幕时,我将收到以下警告一次。

[TableView] Warning once only: UITableView was told to layout itsvisible cells and other contents without being in the view hierarchy(the table view or one of its superviews has not been added to awindow). This may cause bugs by forcing views inside the table view toload and perform layout without accurate information (e.g. table viewbounds, trait collection, layout margins, safe area insets, etc), andwill also cause unnecessary performance overhead due to extra layoutpasses. Make a symbolic breakpoint atUITableViewAlertForLayoutOutsideViewHierarchy to catch this in thedebugger and see what caused this to occur, so you can avoid thisaction altogether if possible, or defer it until the table view hasbeen added to a window. Table view: <UITableView: 0x7fe2ba8d5a00;frame = (-47 -80; 394 553); clipsToBounds = YES; autoresize = RM+BM;gestureRecognizers = <NSArray: 0x600003447480>; layer = <CALayer:0x600003aa2be0>; contentOffset: {0, 0}; contentSize: {394, 176};adjustedContentInset: {0, 0, 0, 0}; dataSource:<Project.MondayToSundayViewController: 0x7fe2b9da05c0>>


当为 UITableViewAlertForLayoutOutsideViewHierarchy 添加符号断点时,控制台中会显示以下内容。
> UIKitCore`UITableViewAlertForLayoutOutsideViewHierarchy:
-> 0x7fff48260c7e <+0>: pushq %rbp
0x7fff48260c7f <+1>: movq %rsp, %rbp
0x7fff48260c82 <+4>: pushq %r14
0x7fff48260c84 <+6>: pushq %rbx
0x7fff48260c85 <+7>: subq $0x30, %rsp
0x7fff48260c89 <+11>: callq *0x3e51a6a1(%rip) ; (void *)0x00007fff51411350: objc_retain
0x7fff48260c8f <+17>: movq %rax, %rbx
0x7fff48260c92 <+20>: leaq 0x416a8dbf(%rip), %rdi ; _UIInternalPreference_UITableViewEnableAlertForLayoutOutsideViewHierarchy
0x7fff48260c99 <+27>: leaq 0x3e5a2140(%rip), %rsi ; @"UITableViewEnableAlertForLayoutOutsideViewHierarchy"
0x7fff48260ca0 <+34>: callq 0x7fff482a7529 ; _UIInternalPreferenceUsesDefault
0x7fff48260ca5 <+39>: testb %al, %al
0x7fff48260ca7 <+41>: jne 0x7fff48260cb3 ; <+53>
0x7fff48260ca9 <+43>: movb 0x416a8dad(%rip), %al ; _UIInternalPreference_UITableViewEnableAlertForLayoutOutsideViewHierarchy + 4
0x7fff48260caf <+49>: andb $0x1, %al
0x7fff48260cb1 <+51>: je 0x7fff48260d2d ; <+175>
0x7fff48260cb3 <+53>: leaq 0x416c3ffe(%rip), %rax ; _UIApplicationLinkedOnVersion
0x7fff48260cba <+60>: movl (%rax), %eax
0x7fff48260cbc <+62>: testl %eax, %eax
0x7fff48260cbe <+64>: je 0x7fff48260d3e ; <+192>
0x7fff48260cc0 <+66>: cmpl $0xd0000, %eax ; imm = 0xD0000
0x7fff48260cc5 <+71>: jb 0x7fff48260d2d ; <+175>
0x7fff48260cc7 <+73>: movq %rbx, %rdi
0x7fff48260cca <+76>: callq 0x7fff486252fa ; symbol stub for: objc_opt_class
0x7fff48260ccf <+81>: movq 0x41607402(%rip), %rsi ; "_isInternalTableView"
0x7fff48260cd6 <+88>: movq %rax, %rdi
0x7fff48260cd9 <+91>: callq *0x3e51a641(%rip) ; (void *)0x00007fff513f7780: objc_msgSend
0x7fff48260cdf <+97>: testb %al, %al
0x7fff48260ce1 <+99>: jne 0x7fff48260d2d ; <+175>
0x7fff48260ce3 <+101>: movq 0x3e519b46(%rip), %rax ; (void *)0x00007fff89ea06a0: _NSConcreteStackBlock
0x7fff48260cea <+108>: movq %rax, -0x38(%rbp)
0x7fff48260cee <+112>: movl $0xc2000000, %eax ; imm = 0xC2000000
0x7fff48260cf3 <+117>: movq %rax, -0x30(%rbp)
0x7fff48260cf7 <+121>: leaq 0x46728(%rip), %rax ; __UITableViewAlertForLayoutOutsideViewHierarchy_block_invoke
0x7fff48260cfe <+128>: movq %rax, -0x28(%rbp)
0x7fff48260d02 <+132>: leaq 0x3e51d237(%rip), %rax ; __block_descriptor_40_e8_32s_e5_v8?0l
0x7fff48260d09 <+139>: movq %rax, -0x20(%rbp)
0x7fff48260d0d <+143>: movq %rbx, %rdi
0x7fff48260d10 <+146>: callq *0x3e51a61a(%rip) ; (void *)0x00007fff51411350: objc_retain
0x7fff48260d16 <+152>: movq %rax, -0x18(%rbp)
0x7fff48260d1a <+156>: cmpq $-0x1, 0x416ca5c6(%rip) ; _UIInternalPreference_TableViewReorderingUsesDragAndDrop_block_invoke_10.__s_category + 7
0x7fff48260d22 <+164>: jne 0x7fff48260d52 ; <+212>
0x7fff48260d24 <+166>: movq %rax, %rdi
0x7fff48260d27 <+169>: callq *0x3e51a5fb(%rip) ; (void *)0x00007fff51411000: objc_release
0x7fff48260d2d <+175>: movq %rbx, %rdi
0x7fff48260d30 <+178>: addq $0x30, %rsp
0x7fff48260d34 <+182>: popq %rbx
0x7fff48260d35 <+183>: popq %r14
0x7fff48260d37 <+185>: popq %rbp
0x7fff48260d38 <+186>: jmpq *0x3e51a5ea(%rip) ; (void *)0x00007fff51411000: objc_release
0x7fff48260d3e <+192>: movl $0xd0000, %edi ; imm = 0xD0000
0x7fff48260d43 <+197>: callq 0x7fff48093724 ; _UIApplicationLinkedOnOrAfter
0x7fff48260d48 <+202>: testb %al, %al
0x7fff48260d4a <+204>: jne 0x7fff48260cc7 ; <+73>
0x7fff48260d50 <+210>: jmp 0x7fff48260d2d ; <+175>
0x7fff48260d52 <+212>: leaq 0x416ca58f(%rip), %rdi ; UITableViewAlertForLayoutOutsideViewHierarchy.once
0x7fff48260d59 <+219>: leaq -0x38(%rbp), %r14
0x7fff48260d5d <+223>: movq %r14, %rsi
0x7fff48260d60 <+226>: callq 0x7fff48624f8e ; symbol stub for: dispatch_once
0x7fff48260d65 <+231>: movq 0x20(%r14), %rax
0x7fff48260d69 <+235>: jmp 0x7fff48260d24 ; <+166>
你能帮我删除警告吗?

最佳答案

在将 View 添加到 View 层次结构之前添加了约束。这就是您收到此错误的原因。
确保依次添加,例如:

view.addSubview(tableView) // 1
// 2 and start adding constraints..
tableView.translatesAutoresizingMaskIntoConstraints = false
...

关于ios - 仅警告一次 : UITableView was told to layout its visible cells and other contents without being in the view hierarchy?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64568183/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com