Skip to content

Instantly share code, notes, and snippets.

@pita5
Created June 17, 2013 20:59
Show Gist options
  • Save pita5/5800359 to your computer and use it in GitHub Desktop.
Save pita5/5800359 to your computer and use it in GitHub Desktop.
#import <objc/runtime.h>
#import <objc/message.h>
__attribute__((constructor)) static void PSPDFFixCollectionViewUpdateItemWhenKeyboardIsDisplayed(void) {
@autoreleasepool {
if ([UICollectionViewUpdateItem class] == nil) return; // pre-iOS6.
if (![UICollectionViewUpdateItem instancesRespondToSelector:@selector(action)]) {
IMP updateIMP = imp_implementationWithBlock(^(id _self) {});
Method method = class_getInstanceMethod([UICollectionViewUpdateItem class], @selector(action));
const char *encoding = method_getTypeEncoding(method);
if (!class_addMethod([UICollectionViewUpdateItem class], @selector(action), updateIMP, encoding)) {
PSPDFLogError(@"Failed to add action: workaround");
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment