-1

Similarly to this website "Move From UITextField to UITextView When Return Pressed", my cursor appears one line below the intended line. I have tried to use this link as my reference but there didn't seem to be a finalised answer that I could use.

I have also tried

[self.memoTextView performSelector:@selector(becomeFirstResponder) withObject:nil afterDelay:0.0];

but weirdly it work for my simulator but not my device.

Community
  • 1
  • 1
Rach
  • 1
  • 5
  • Have you tried a delay of 0.1 rather than 0.0? When the simulator behaves differently than a device, it may be a timing issue. – Dave Batton Jan 20 '16 at 06:21
  • It works! Why is that, if its no trouble to explain? How does the delay affect the line spacing? – Rach Jan 20 '16 at 08:40
  • After you run some code to move things around on the screen, the updates don't get drawn to the screen instantly. There are a couple of different passes that the OS must take to do calculations, update the GPU, etc. (I'm guessing - that's all beyond my pay grade). Sometimes in your code you want to apply a change based on those calculations that haven't happened yet. Or you want the screen to update before it applies more of your changes (for animations usually). By delaying for 0.1 second (usually enough) you give the OS a chance to update the screen, and you continue from there. – Dave Batton Jan 20 '16 at 18:10
  • Thanks Dave! That helped a lot. – Rach Jan 21 '16 at 02:55

1 Answers1

-1

Using

[self.memoTextView performSelector:@selector(becomeFirstResponder) withObject:nil afterDelay:0.1];

I am able to navigate from UITextField to UITextView using the Return Key. The error was due to a delay of 0.1 when using the device.

Rach
  • 1
  • 5