Last active
October 13, 2015 15:18
-
-
Save acoomans/4215817 to your computer and use it in GitHub Desktop.
Customize FilePicker private Controller by rerouting
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/message.h> | |
IMP tableView_cellForRowAtIndexPath = nil; | |
IMP viewDidAppear = nil; | |
CGFloat myMethodIMP(id self, SEL _cmd, UITableView *tableView, int section) { | |
// implementation .... | |
NSLog(@"%@", tableView); | |
NSLog(@"%d", section); | |
if (section) return 70; | |
return 0; | |
} | |
UITableViewCell *myMethodIMP2(id self, SEL _cmd, UITableView *tableView, NSIndexPath *indexPath) { | |
// implementation .... | |
UITableViewCell *cell = tableView_cellForRowAtIndexPath(self, _cmd, tableView, indexPath); | |
UIView *v = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 200, 200)]; | |
v.backgroundColor = [UIColor redColor]; | |
cell.backgroundView = v; | |
return cell; | |
} | |
void myMethodIMP3(id self, SEL _cmd, BOOL animated) { | |
// implementation .... | |
NSLog(@"%@", ((UIViewController*)self).navigationController.viewControllers); | |
} | |
Class cls = NSClassFromString(@"FPSourceListController"); | |
tableView_cellForRowAtIndexPath = class_getMethodImplementation(cls, @selector(tableView:cellForRowAtIndexPath:)); | |
viewDidAppear = class_getMethodImplementation(cls, @selector(viewDidAppear:)); | |
class_replaceMethod(cls, @selector(tableView:heightForHeaderInSection:), (IMP) myMethodIMP, "f@:@i"); | |
class_replaceMethod(cls, @selector(tableView:cellForRowAtIndexPath:), (IMP) myMethodIMP2, "f@:@i"); | |
class_replaceMethod(cls, @selector(viewDidDisappear:), (IMP) myMethodIMP3, "v@:"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment