Last active
August 3, 2021 10:08
Revisions
-
n-b revised this gist
Apr 19, 2013 . 2 changed files with 0 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,9 +1,7 @@ // // NBResponderChainUtilities.h // // Created by Nicolas @ bou.io on 19/04/13. // #import <UIKit/UIKit.h> This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,9 +1,7 @@ // // NBResponderChainUtilities.m // // Created by Nicolas @ bou.io on 19/04/13. // #import "NBResponderChainUtilities.h" -
n-b revised this gist
Apr 19, 2013 . 2 changed files with 11 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -17,7 +17,7 @@ @end @interface UIResponder (NBResponderChainUtilities) - (NSArray*) nb_responderChain; // List the -nextResponder starting at the receiver @end This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,10 @@ (lldb) po NBResponderChain() $13 = 0x213dda70 <__NSArrayI 0x213dda70>( <UIActionSheet: 0x11915160; frame = (0 231; 320 337); opaque = NO; layer = <CALayer: 0x222b9c30>>, <UIView: 0x222c73b0; frame = (0 0; 320 568); opaque = NO; layer = <CALayer: 0x2229d2f0>>, <UIView: 0x2229d340; frame = (0 0; 320 568); opaque = NO; layer = <CALayer: 0x2229d3a0>>, <UIView: 0x11913dc0; frame = (0 0; 320 568); clipsToBounds = YES; layer = <CALayer: 0x2229d3d0>>, <_UIAlertOverlayWindow: 0x2226d4e0; frame = (0 0; 320 568); layer = <UIWindowLayer: 0x11911900>>, <UIApplication: 0xaa66b30>, <BicycletteApplicationDelegate: 0xab78c60> ) -
n-b revised this gist
Apr 19, 2013 . 2 changed files with 53 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,25 @@ // // NBResponderChainUtilities.h // // // Created by Nicolas @ bou.io on 19/04/13. // Copyright (c) 2013 Nicolas Bouilleaud. All rights reserved. // #import <UIKit/UIKit.h> @interface UIView (NBResponderChainUtilities) - (UIView*) nb_firstResponder; // Recurse into subviews to find one that responds YES to -isFirstResponder @end @interface UIApplication (NBResponderChainUtilities) - (UIView*) nb_firstResponder; // in the -keyWindow @end @interface UIResponder (NBResponderChainUtilities) - (NSArray*) nb_responderChain; // List the -nextResponder starting at the receiver. @end UIView * NBFirstResponder(void); // in the app key window NSArray * NBResponderChain(void); // Starting at the first responder This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,15 +1,23 @@ // // NBResponderChainUtilities.m // // // Created by Nicolas @ bou.io on 19/04/13. // Copyright (c) 2013 Nicolas Bouilleaud. All rights reserved. // #import "NBResponderChainUtilities.h" @implementation UIView (NBResponderChainUtilities) - (UIView*) nb_firstResponder { if ([self isFirstResponder]){ return self; } for (UIView *subView in self.subviews) { UIView *firstResponder = [subView nb_firstResponder]; if (firstResponder != nil) { return firstResponder; @@ -19,11 +27,26 @@ - (UIView*) nb_FirstResponder } @end @implementation UIApplication (NBResponderChainUtilities) - (UIView*) nb_firstResponder { return [[self keyWindow] nb_firstResponder]; } @end @implementation UIResponder (NBResponderChainUtilities) - (NSArray*) nb_responderChain { return [@[self] arrayByAddingObjectsFromArray:[self.nextResponder nb_responderChain]]; } @end UIView * NBFirstResponder(void) { return [[UIApplication sharedApplication] nb_firstResponder]; } NSArray * NBResponderChain(void) { return [NBFirstResponder() nb_responderChain]; } -
n-b renamed this gist
Apr 19, 2013 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,4 @@ @implementation UIView (FirstResponder) - (UIView*) nb_FirstResponder -
n-b created this gist
Apr 19, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,30 @@ @implementation UIView (FirstResponder) - (UIView*) nb_FirstResponder { if ([self isFirstResponder]){ return self; } for (UIView *subView in self.subviews) { UIView *firstResponder = [subView nb_FirstResponder]; if (firstResponder != nil) { return firstResponder; } } return nil; } @end @implementation UIResponder (chain) - (NSArray*) nb_responderChain { return [@[self] arrayByAddingObjectsFromArray:[self.nextResponder nb_responderChain]]; } @end