Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Sorted! I simply use a 1x1px text view and use the delegate method <code>textViewDidChangeSelection:</code></p> <p><strong>EDIT: For iOS 6 I had to change the text view to 50x50px (or at least enough to actually display text) for this to work</strong></p> <p>I also managed to suppress the on-screen keyboard when the pedal is disconnected.</p> <p>This is my code in viewDidLoad:</p> <pre><code>[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillAppear:) name:UIKeyboardWillShowNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillDisappear:) name:UIKeyboardWillHideNotification object:nil]; UITextView *hiddenTextView = [[UITextView alloc] initWithFrame:CGRectMake(0, 0, 50, 50)]; [hiddenTextView setHidden:YES]; hiddenTextView.text = @"aa"; hiddenTextView.delegate = self; hiddenTextView.selectedRange = NSMakeRange(1, 0); [self.view addSubview:hiddenTextView]; [hiddenTextView becomeFirstResponder]; if (keyboardShown) [hiddenTextView resignFirstResponder]; </code></pre> <p><code>keyboardShown</code> is declared as a <code>bool</code> in my header file.</p> <p>Then add these methods:</p> <pre><code>- (void)textViewDidChangeSelection:(UITextView *)textView { /******TEXT FIELD CARET CHANGED******/ if (textView.selectedRange.location == 2) { // End of text - down arrow pressed textView.selectedRange = NSMakeRange(1, 0); } else if (textView.selectedRange.location == 0) { // Beginning of text - up arrow pressed textView.selectedRange = NSMakeRange(1, 0); } // Check if text has changed and replace with original if (![textView.text isEqualToString:@"aa"]) textView.text = @"aa"; } - (void)keyboardWillAppear:(NSNotification *)aNotification { keyboardShown = YES; } - (void)keyboardWillDisappear:(NSNotification *)aNotification { keyboardShown = NO; } </code></pre> <p>I hope this code helps someone else who is looking for a solution to this problem. Feel free to use it.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload