我有以下代码
// Breakpoint here
[label removeFromSuperview];
[label release];
label = nil;
使用调试器输出
逐步执行它(gdb) po [self subviews]
<NSCFArray 0x476af70>(
<UIImageView: 0x47581a0; frame = (0 0; 232 81); opaque = NO; autoresize = W+H; userInteractionEnabled = NO; layer = <CALayer: 0x476b3d0>>,
<UILabel: 0x4758870; frame = (15 11; 202 56); text = 'Test'; clipsToBounds = YES; autoresize = W+H; userInteractionEnabled = NO; layer = <CALayer: 0x476b590>>
)
(gdb) po label
<UILabel: 0x4758870; frame = (15 11; 202 56); text = 'Test'; clipsToBounds = YES; autoresize = W+H; userInteractionEnabled = NO; layer = <CALayer: 0x476b590>>
(gdb) n
(gdb) n
(gdb) n
(gdb) po [self subviews]
<NSCFArray 0x478c4e0>(
<UIImageView: 0x47581a0; frame = (0 0; 232 81); opaque = NO; autoresize = W+H; userInteractionEnabled = NO; layer = <CALayer: 0x476b3d0>>
)
然而它仍然可见,它并没有消失。即使我之后立即[self setNeedsDisplay]
也不行。
还有其他人遇到过这个吗?它是SDK中的错误还是我遗漏了什么?
答案 0 :(得分:0)
事实证明,我的代码中的一个错误会导致多个相同的视图相互创建,从而导致此行为。