Search code examples
uitableviewuitextviewfirst-responder

UITextView in a UITableViewCell: first responder problem


I have a UITextView in a UITableViewCell which grows together with it. Using

[myTableView beginUpdates];
[myTableView endUpdates];

in textViewDidChange and setting the height of the cell properly, I'm getting close to the solution. But I've a problem tied to the first responder. I set the textview in my custom cell to become the first responder ('cause I want to start with the open keyboard) on the view loading, but the textview is nil in viewDidLoad, viewWillAppear, viewDidAppear, only when I write a char I can see it's not nil.

I connected the textview in the IB custom cell with an IBOutlet in my viewcontroller.


Solution

  • I resolved putting

    [myTextView becomeFirstResponder];
    

    in

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;