9

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

madth3
  • 7,275
  • 12
  • 50
  • 74
Craig Warren
  • 1,655
  • 4
  • 23
  • 38
  • 0 The alarming portion is that the textViewDidBeginEditing isn't being called. I assume that prior to your processing being run, textViewDidBeginEditing was called correctly, is that correct? Then when processing stops, they UITextFields re-enable themselves but see someone else as their delegates? Is that right? – justin Jan 25 '10 at 15:41
  • Yes the delegate method run normally when the fields are enabled. When disabled they will not respond to anything. When re-enabled they the last field to be touched has the keyboard active, but its delegate methods have not been run. – Craig Warren Jan 25 '10 at 15:44
  • When they re-enable due to user touch, the delegate methods are not called. If they re-enable because processing is complete, the delegate methods do run (I assume). None of the delegate methods are called, so you can't return NO to textFieldShouldBeginEditing. you've disabled the controls by doing controlvariable.enabled = NO – justin Jan 25 '10 at 16:30

3 Answers3

2

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

Craig Warren
  • 1,655
  • 4
  • 23
  • 38
  • I'm having a similar problem with a UITextView and the Editable flag. I suspect it's a related issue. I also suspect that this issue was cleared up in 4.0 or earlier, since I only have this problem when compiling for the iPad which still runs on 3.2 – Ash Sep 25 '10 at 16:15
1

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

Harry Joy
  • 58,650
  • 30
  • 162
  • 207
bio
  • 669
  • 4
  • 14
0

Did you try resigning first responder when text becomes inactive instead of when it becomes active?

DenNukem
  • 8,014
  • 3
  • 40
  • 45