Meg*_*aur 2 iphone delegates uitextfield
我最近尝试将UITextField子类化并将委托设置为我自己(发现这个尝试解决了我的问题:http://www.cocoabuilder.com/archive/cocoa/241465-iphone-why-can-a-uitextfield-be-its -own-delegate.html)
@interface MyObject :UITextField <UITextFieldDelegate>
@end
@implementation MyObject
-(id) initWithFrame:(CGRect) frame
{
if((self=[super initWithFrame:frame]))
{
self.delegate=self;
}
return self;
}
-(BOOL) respondsToSelector:(SEL)selector
{
NSLog(@"responds to selector");
return [super respondsToSelector:selector];
}
// Implement all the missing methods
@end
Run Code Online (Sandbox Code Playgroud)
调用接口上定义的方法会导致无限递归.我在Apple文档中没有看到任何定义在一个委托在场的情况下responsesToSelector应该如何表现的内容.