Last active
December 26, 2015 04:19
-
-
Save maddiesch/7092414 to your computer and use it in GitHub Desktop.
Blog Post On Auto Layout
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
#import <objc/runtime.h> | |
NS_INLINE void xx_MethodSwizzle(Class c, SEL origSEL, SEL overrideSEL) { | |
Method origMethod = class_getInstanceMethod(c, origSEL); | |
Method overrideMethod = class_getInstanceMethod(c, overrideSEL); | |
if(class_addMethod(c, origSEL, method_getImplementation(overrideMethod), method_getTypeEncoding(overrideMethod))) { | |
class_replaceMethod(c, overrideSEL, method_getImplementation(origMethod), method_getTypeEncoding(origMethod)); | |
} else { | |
method_exchangeImplementations(origMethod, overrideMethod); | |
} | |
} | |
@interface UITableView (AutoLayoutFixForRefreshIndicatorInTableView) | |
@end |
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
@implementation UITableView (PCOKitAutoLayoutFixForRefreshIndicatorInTableView) | |
+ (void)load { | |
xx_MethodSwizzle(self, @selector(layoutSubviews), @selector(xx_autoLayoutLayoutSubviews)); | |
} | |
- (void)xx_autoLayoutLayoutSubviews { | |
[self xx_autoLayoutLayoutSubviews]; // Call the original implementation | |
[super layoutSubviews]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment