補足ビューはUICollectionReusableView
、 ではなく、 (またはそのサブクラス) である必要がありUICollectionViewCell
ます。
いずれにせよ、ボタンが反応しない場合、最初にすべきことは、すべての祖先ビューが にuserInteractionEnabled
設定されていることを確認することYES
です。ボタンが画面に表示されたら、デバッガーで一時停止し、次の操作を行います。
(lldb) po [[UIApp keyWindow] recursiveDescription]
リストでボタンを見つけて、そのアドレスをコピーします。次に、それと各スーパービューを確認できます。例:
(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>
ここで、ルート ( ) までのすべてのビューがからUIWindow
返されることがわかりました。ウィンドウのスーパービューは nil です。YES
isUserInteractionEnabled