Created
September 12, 2011 14:14
-
-
Save AlanQuatermain/1211349 to your computer and use it in GitHub Desktop.
Sharing UIView subclasses between iPhone and iPad? Make your life easier with device-specific -layoutSubviews (or -drawRect, etc.) methods. Make the Objective-C runtime work for YOU!
This file contains 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 characters
+ (void) initialize | |
{ | |
if ( self != [KBCommentEditorView class] ) | |
return; | |
// install the device-appropriate version of -layoutSubviews | |
Method m1 = class_getInstanceMethod(self, @selector(layoutSubviews)); | |
Method m2 = class_getInstanceMethod(self, IsPad() ? @selector(layoutSubviewsIPad) : @selector(layoutSubviewsIPhone)); | |
method_exchangeImplementations(m1, m2); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment