Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7715777
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T02:28:19+00:00 2026-06-01T02:28:19+00:00

I discovery one thing. If i set yes to function – textField:shouldChangeCharactersInRange:replacementString: The cursor

  • 0

I discovery one thing. If i set yes to function

- textField:shouldChangeCharactersInRange:replacementString:

The cursor stay in the same place I type, like (“|” = cursor)

"|"     => Empty , type a
"a|"    => type b
"ab|"   => change cursor
"a|b"   => type c
"ac|b"  => type d
"acd|b" => change cursor
"ac|db" => type backspace
"a|db"  => type backspace again
"|db"   => *result*

But, if I have to change the text, like put a "-" in penultimate character, I do the logic thing and set the text with:

  [textField setText:newText];

But the sample above will be in this way:

"|"      => Empty , type a
"a|"     => type b               (put character "-" automatic)
"a-b|"   => user change cursor
"a|-b"   => type c    
"ac-b|"  => type d               ## the cursor is in end ##
"acb-d|" => change cursor        ## "d" is in wrong place, the user have to  
                                 ## change cursor to reproduce the result above
"ac|b-d" => type backspace
"ab-d|"  => type backspace again   ## the cursor is in end again ##
"a-b|"   => *result*               ## I want delete "a" but it delete "d"

How can I set the cursor to the result is the same "|d-b" like in the first sample? Or better question: How change the text and the cursor in a UITextField?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T02:28:21+00:00Added an answer on June 1, 2026 at 2:28 am

    I found the solution. I can’t choice the cursor place, but it do what I want. You have to use the function of protocol UIKeyInput There are 2 good function:

    - (void)insertText:(NSString *)text;
    - (void)deleteBackward;
    

    Than, redoing my test case, I have:

    "|"      => Empty , type a
    "a|"     => type b               (put character "-" automatic)
    "a-b|"   => user change cursor
    "a|-b"   => type c               (enter the character with a [textField insertText:@"c"]
    "ac|-b"  => type d               (the same thing: [textField insertText:@"d"])
    "acd|-b" => change cursor
    "ac|d-b" => type backspace       (use a [textField deleteBackward])
    "a|d-b"  => type backspace
    "|d-b"   => *result*             (Work!!!)
    

    You can’t change the cursor, but for normal typing it solve the problems!.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just installed Wordpress, and one thing I discovered is that site URL appears
I am thinking of one thing, since for(var i in obj) can pretty much
We have discovered that one of our auto generated assemblies is throwing a StackOverflowException
One of the memory leaks I've discovered in our application is the java.awt.Window.allWindows private
Discovered something and am looking into a bit of incite as to why one
I am building an rss feed discovery service by scraping a page URL and
Is there a tool for automated test discovery for .NET. I am using the
Are there any implementations of the WS-Discovery specification for JAX-WS RI, Axis2, CXF or
I'm working on an app using Bluetooth discovery pretty heavily (some detail here ).
I can't find anything on the implementation of service discovery for the ASP.NET Web

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.