So, I have a UITextField
subclass which is it\'s own Delegate
and is crashing when keyboard shortcuts are used. It maxes out on CPU
an
I encountered the same issue today when working with a self-delegating UITextField
subclass. If it is not possible to change the delegate to something other than self, I would recommend overriding respondsToSelector
rather than implementing a customOverlayContainer
method that may return an invalid object (are you sure it's supposed to be an instance of UITextField
? How do you know iOS isn't asking for a UIView
or a CGLayer
or any other type of object?)
-(BOOL) respondsToSelector:(SEL)aSelector {
NSString * selectorName = NSStringFromSelector(aSelector);
if ([selectorName isEqualToString:@"customOverlayContainer"]) {
NSLog(@"preventing self.delegate == self crash");
return NO;
}
return [super respondsToSelector:aSelector];
}
Problem solved by changing the delegate to the object which inits my text view.
I solved this by custom customOverlayContainer and return the textFiled. eg.
@implementation CustomTextField
- (id)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
self.delegate = self;
}
return self;
}
- (id)customOverlayContainer {
return self;
}
@end
Tested on iOS 7 and iOS 6.