补充视图应该是 a UICollectionReusableView
(或其子类),而不是UICollectionViewCell
.
无论如何,如果按钮没有响应,首先要做的是检查其所有祖先视图是否已userInteractionEnabled
设置为YES
. 一旦按钮出现在屏幕上,在调试器中暂停并执行以下操作:
(lldb) po [[UIApp keyWindow] recursiveDescription]
在列表中找到按钮并复制其地址。然后你可以检查它和每个superview。例子:
(lldb) p (BOOL)[0xa2e4800 isUserInteractionEnabled]
(BOOL) $4 = YES
(lldb) p (BOOL)[[0xa2e4800 superview] isUserInteractionEnabled]
(BOOL) $5 = YES
(lldb) p (BOOL)[[[0xa2e4800 superview] superview] isUserInteractionEnabled]
(BOOL) $6 = YES
(lldb) p (BOOL)[[[[0xa2e4800 superview] superview] superview] isUserInteractionEnabled]
(BOOL) $8 = YES
(lldb) p (BOOL)[[[[[0xa2e4800 superview] superview] superview] superview] isUserInteractionEnabled]
(BOOL) $9 = YES
(lldb) p (BOOL)[[[[[[0xa2e4800 superview] superview] superview] superview] superview] isUserInteractionEnabled]
(BOOL) $10 = NO
(lldb) po [[[[[0xa2e4800 superview] superview] superview] superview] superview]
(id) $11 = 0x00000000 <nil>
在这里,我发现直到根 (the UIWindow
)的所有视图都YES
从isUserInteractionEnabled
. 窗口的超级视图为零。