I want to insert a view below the viewcontroller.view. My idea is to exchange viewcontroller.view with a tempview at runtime.
In "UIViewController+Ext.m":
+ (void)load {
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
Class vc = [UIViewController class];
SEL originalSEL = @selector(viewDidLoad);
SEL swizzledSEL = @selector(Easy_viewDidLoad);
Method originalMethod = class_getInstanceMethod(vc, originalSEL);
Method swizzledMethod = class_getInstanceMethod(vc, swizzledSEL);
BOOL didAddMethod =
class_addMethod(vc, originalSEL, method_getImplementation(swizzledMethod), method_getTypeEncoding(swizzledMethod));
if (didAddMethod) {
class_replaceMethod(vc, swizzledSEL, method_getImplementation(originalMethod), method_getTypeEncoding(originalMethod));
}
else {
method_exchangeImplementations(originalMethod, swizzledMethod);
}
});
}
- (void)Easy_viewDidLoad
{
UIView *view = self.view ;
UIView *tempV = [[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth(), ScreenHeight())];
tempV.backgroundColor = [UIColor cyanColor];
self.view = tempV ;
view.frame = CGRectMake(0, NavigationHeight(), ScreenWidth(), ScreenHeight()-NavigationHeight());
[self.view addSubview:view];
[self Easy_viewDidLoad];
}
When I add a UITextField on the view controller, the textfield becomes first responder. But the app is killed and throws this error:
-[UIView leftDockItem]: unrecognized selector sent to instance 0x7f91bb742d80
- What is the leftDockItem
- What is the base way to add a view below viewcontroller.view?