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 3845046
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T16:11:01+00:00 2026-05-19T16:11:01+00:00

I am building a virtual keyboard for a UITextView. All works well, I can

  • 0

I am building a virtual keyboard for a UITextView. All works well, I can display the keyboard and remove the keyboard as well as display the keystrokes. I am using the “stringByReplacingCharactersInRange: withString” method to place the new keystroke into the text view. This works but since it is replacing the string each time, the entry point goes to the end of the string. This all makes sense, but is not very usable. I can fix this by doing checks in my code but there might be something better…

So my question is this; Is there a way to push the new key to the UITextView directly without modifying the UITextView’s text property’s string manually? The manual states that I will have to manage the target/action myself, but I was wondering if I’ve missed an action to call. It seems that the Apple Default keyboard must have a slick way of punching the keystroke into the object without the obvious number of checks that I will have to do to make the typing smooth.

Any help will be greatly appreciated.
Thanks,
Rob

  • 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-05-19T16:11:02+00:00Added an answer on May 19, 2026 at 4:11 pm

    Well, I didn’t get any responses. So I figured out a way to do it so it is reasonable and simple. It’s a matter of tracking the selected range. So when I wish to Backspace I use this technique.

    NSRange currentRange = self.myTextView.selectedRange;
    if (currentRange.length == 0) {
        currentRange.location--;
        currentRange.length++;
    }
    self.myTextView.text = [self.myTextView.text stringByReplacingCharactersInRange:currentRange withString:[NSString string]];
    currentRange.length = 0;
    self.myTextView.selectedRange = currentRange;
    

    If I need to type a character this works.

    NSRange currentRange = self.myTextView.selectedRange;
    self.myTextView.text = [self.myTextView.text stringByReplacingCharactersInRange:currentRange withString:someCharacter];
    currentRange.location++;
    currentRange.length = 0;
    self.myTextView.selectedRange = currentRange;
    

    If anyone has a better way, I’d like to hear it.

    Thanks,
    Rob

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

Sidebar

Related Questions

i'm building a message system for a virtual community, but i can't take the
I've been building my sample asp.net application using VWD2008 and the development virtual server
Virtual memory is well-supported by modern hardware, but application-level memory allocation is still all
I'm building a virtual keyboard that assigns images to keycodes, and appends them in
I am building an application that has virtual windows. The output is TImage object.
building a site using PHP and MySQL that needs to store a lot of
My question is building on this question: Correct way to inherit from a virtual
I'm having trouble building Protocol Buffers for Android using a standalone NDK toolchain created
I'm building an auction site and the user can bid on the same item
I recently started building a domain at home using nhibernate 3 and fluent nhibernate

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.