5

I've run into a problem with the UITextView that seems to be related to having a scrollable view within a scrollable view.

In order to remedy this i thought i would attempt to write my own multiline (but not scrollable) text view. Given the core graphics methods, and the UITextInputTraits class it seems like this should be feasable. The only thing i cant figure out is wether or not its possible to display (and catch events) for the system wide keyboard.

Is this even possible using the SDK?

Cezar
  • 55,636
  • 19
  • 86
  • 87
Lounges
  • 4,674
  • 5
  • 32
  • 43
  • I was curious if you ever got your multiline view working and, if so, how you handled word wrap? I am attempting to make a similar thing (only editable, scrollable and does syntax highlighting) but I am stuck on word wrap. Thanks. – Kyle May 13 '09 at 00:47
  • Why don't you just use an UITextView and disable it's scrolling? – Andrei Filip Sep 06 '12 at 09:22

1 Answers1

7

What I did in a similar situation, is made a hidden UITextField, and set its delegate to your class where you can implement the appropriate UITextFieldDelegate methods to intercept the key's pressed.

something like this:

UITextField *myHiddenTextField = [[UITextField alloc] initWithFrame: cgRectZero()];
myHiddenTextField.delegate = self;
[myHiddenTextField becomeFirstResponder];

- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
//use string here for the text input
return false;
}
Brad The App Guy
  • 16,255
  • 2
  • 41
  • 60