lagos lagos - 17 days ago 11
Objective-C Question

UITextView not becoming first responder

I have a

UIView
that contains a
UITextView
. The
UIView
is initiated inside a
UIViewController
.

But when I touch the
UITextView
box, nothing happens. Neither the keyboard appears nor delegate methods respond to interaction.

Code:

noteText = [[UITextView alloc]initWithFrame:CGRectMake(0, 0, 700, 240)];
noteText.layer.borderColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.2].CGColor;
noteText.layer.borderWidth = 2;
[noteText setEditable:YES];
noteText.userInteractionEnabled = YES;
noteText.returnKeyType = UIReturnKeyDone;
noteText.font = [UIFont fontWithName:@"Calibri" size:16];
noteText.textColor = [UIColor blackColor];
[self addSubview:noteText];


Update 1

I removed all other views from the UIViewController, and only put a UITextView in the UIViewController and still not reacting. Neither cursor or keyboard appear.

Answer

I found the error.

In one class I categorize the UITextView instead of subclass and set canBecomeFirstResponder to NO.