I have textView in my cell and sometimes during tableView scroll some weird calls happen. System make my textView first responder. I've found these calls do unwanted behavior:
#0 -[UITextView canBecomeFirstResponder] ()
#1 -[UIView(Hierarchy) deferredBecomeFirstResponder] ()
#2 -[UIView(Hierarchy) _promoteDescendantToFirstResponderIfNecessary] ()
I can't find out why are these called, so I've tried to deal with this by extending UITextView
and overriding - canBecomeFirstResponder
.
Here is my .h:
#import <UIKit/UIKit.h>
@protocol TextViewDelegate;
@interface TextView : UITextView
@property (nonatomic, assign) id<TextViewDelegate> delegate;
@end
@protocol TextViewDelegate <UITextViewDelegate>
- (BOOL)canBecomeFirstResponder:(TextView *)textView;
@end
And .m:
#import "TextView.h"
@implementation TextView
@synthesize delegate;
- (BOOL)canBecomeFirstResponder
{
return [self.delegate respondsToSelector:@selector(canBecomeFirstResponder:)] ? [self.delegate canBecomeFirstResponder:self] : NO;
}
@end
This solution works but on the line @property (nonatomic, assign) id<TextViewDelegate> delegate;
I've got warning and I don't know why. It says Property type 'id<TextViewDelegate>' is incompatible with type 'id<UITextViewDelegate>' inherited from 'UITextView'
.
So why system want to make textView first responder if I do not? Why I'm getting this warning? Is there better solution than mine?