Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPhone UITextView which is disabled becomes first responder when re-enabled

I have an application which has some text views on one of the controllers. When the application is processing these text views are disabled and have their user interaction disabled.

The problem is that when the text views are re-enabled they respond to any touches made when they where disabled.

This is made even worse because they become the first responder but the code I have written for textViewDidBeginEditing is NOT run... this means that instead of having the done button on the top right of the Nav Bar instead it still presents the submit button instead.

I have tried automatically resigning first responder when they become active but this has no effect.

Does anyone know why these clicks while deactivated take effect when re-enabled and how to stop them. Bear in mind I have tried to resign first responder and disabled user interaction already.

Thanks Craig

EDIT:

I've just noticed that this problem is not caused by clicks while inactive, but because setting the UITextView to enabled causes it to display the keyboard.

This is a known defect since iPhone OS 2.1... Release note for 2.2

like image 385
Craig Warren Avatar asked Jan 25 '10 15:01

Craig Warren


2 Answers

This is an bug known since iPhone OS 2.1. When you call UITextView.enabled = YES the keyboard appear, see the release note for OS 2.2 Release Note

The workaround is not to useUITextView.enabled at all, instead use [UITextView setUserInteractionEnabled:] when you want to enable or disable the UITextView.

Craig

like image 172
Craig Warren Avatar answered Oct 22 '22 19:10

Craig Warren


UITextView does not have a property called enabled. You should use editable instead.

like image 22
bio Avatar answered Oct 22 '22 18:10

bio