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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:21:38+00:00 2026-05-27T01:21:38+00:00

I want to set the marked text programmatically and since iOS5 UITextView and UITextField

  • 0

I want to set the marked text programmatically and since iOS5 UITextView and UITextField conform to UITextInput this should be possible but for some reason I always get the markedText to be nil. 🙁
What am I missing here?

This is what I’ve tried without success:

(While the textview is firstResponder)

1.- When the text view contains no text:

text: "", selectedRange : {0,0}, markedText: nil.

[_textView setMarkedText:@"月" selectedRange:NSMakeRange(0, 1)];

Result:
text : "", selectedRange: {0,0}, markedText: nil. (Nothing changed)

2.- When the text view contains text + some marked text:

text : "AAA", selectedRange = {0,3}, marked text at the end : "太陽"
then I do:

[_textView setMarkedText:@"地" selectedRange:NSMakeRange(0,3)];

Result :
text :"AAA", selectedRange: {0,3}, markedText: nil; (the marked text became nil)

In both cases is like setMarkedText:selectedRange: would be setting the current marked text (if some) to nil.

Any help would be highly appreciated 🙂

UPDATE

Since the concept of marked text seems to be unclear, here is an explanation:

In multi stage input languages (e.g. Japanese) you can input regular text (like english) or input marked text (like japanese).

Here I wrote regular text : regular text then I wrote marked text つ
and then I wrote marked text き so it was appended becoming つき.

Marked text (text in the blue box) represents a transitional or intermediate input stage because it can become into other characters/words called candidates. Candidates are shown in the big box.

This screenshot was taken when using a bluetooth keyboard in the iPad but you will get similar results when using the software keyboard when writing japanese for example.

Before writing つ the textview was:

textView.text : "regular text"
textView.selectedRange : {12,0}
textView.markedText:nil

Then I wrote つ and the text view became:

textView.text : "regular textつ"
textView.selectedRange : {13,0}
textView.markedText: "つ"

Then I wrote き and the text view became:

textView.text : "regular textつき"
textView.selectedRange : {14,0}
textView.markedText: "つき"

Which is the current state of the text view.

I want to be able to set the marked text programatically 🙂

Is this possible? — According to UITextInput docs it is.

enter image description here

  • 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-27T01:21:39+00:00Added an answer on May 27, 2026 at 1:21 am

    I have a conceptual problem with your code here. I may just be overlooking some small thing, but I think you just have a simple error in your programming.

    1) When the text view contains no text: text: "", selectedRange : {0,0}, markedText: nil:

    [_textView setMarkedText:@"月" selectedRange:NSMakeRange(0, 1)];
    
    Result: text: "", selectedRange: {0,0}, markedText: nil. 
    

    (Nothing changed)

    2) When the text view contains text + some marked text: text: "AAA", selectedRange: {0,3}, markedText at the end: “太陽” then I do:

    [_textView setMarkedText:@"地" selectedRangeNSMakeRange(0,3)];
    
    Result: text: "AAA", selectedRange: {0,3}, markedText: nil; 
    

    (the marked text became nil)

    I just fixed your problem in the code that I ran in Xcode. It ran flawlessly and changed the marked text when I clicked three different buttons. When there was no marked text, the text was appended and marked.

    text is the name of a UITextView:

    -(IBAction)first
    {
        [text setMarkedText:@"test" selectedRange:NSMakeRange(0, 4)];
    }
    -(IBAction)second
    {
        [text setMarkedText:@"woo" selectedRange:NSMakeRange(0,4)];
    }
    

    Here I clicked “First”
    When First is Clicked

    Here I clicked “Second”
    When Second is Clicked

    I hope this helps you and is deserving of the bounty.

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

Sidebar

Related Questions

I am not sure if this is possible but I want to iterate through
I want set Listbox background to transparent but not working Is there any idea?
I want to set a breakpoint on the __DoPostBack method, but it's a pain
I want to set some attributes just before the object is serialized, but as
I want set interfaceOrientation in one UIView as LandscapeLeft and Portrait in other UIView.
i want set the visibility to itemized overlay in map view. if the zoom
I want to set something up so that if an Account within my app
I want to set all the fields and labels on a VFP7 report to
I want to set a background image for a div, in a way that
I want to set up a Subversion server installation on Windows Server 2003 64-bit

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.