Cursor not showing up in UITextView

33,738

Solution 1

You may have changed the tint color in your custom UITextView. If the tint color is the same as the background color (normally white), then it will appear invisible.

Solution 2

You might be setting improperly a contentSize and/or frame for the component so it is too small to be visible or the control is out of the screen. Please go in Simulator to Debug->Color Blended Layers to see whether those values are set correctly.

EDIT:

With new Xcodes (probably introduced in Xcode 6) you can debug this kind of issues by clicking "Debug View Hierarchy" (it is one of the icons on the bottom bar)

Solution 3

The textfield is showing the cursor but you are not able to see the color, just because the tint color of your text field is set to default most probably as in my case it was. Just select you textField in storyboard and Select the link color of your wish. Refer to the image attached.

enter image description here

Solution 4

I changed the tint color of all of my UITextViews and the cursor started showing on the next build.

Solution 5

Simple workaround seems to work by introducing a delay and then calling firstResponder, like so:

-(void)begin{

    [self performSelector:@selector(first) withObject:nil afterDelay:0.01f];
}
-(void)first{

    [tf becomeFirstResponder];
}
Share:
33,738
SeanT
Author by

SeanT

Updated on July 05, 2022

Comments

  • SeanT
    SeanT almost 2 years

    Can anyone think of a reason that the blinking cursor would not show up in a UITextView? I have a custom control that is just a subclass of UIView and it has a UITextView in it, but the cursor doesn't appear when it gets focus. The keyboard appears, and the text appears as you type, but there is no cursor, and I can't figure out why.

    Any thoughts?...

  • Pierre-Luc Pineault
    Pierre-Luc Pineault over 10 years
    This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post.
  • Julian
    Julian over 10 years
    author wanted some ideas why he does not see the cursor so my idea is that frames of the whole component or part of it (one of the property) might be badly set. This can solve his problem as it might be his problem in fact. He didn't provide any code fragment so all we can is guessing based on knowledge. If you still feel that I didn't answer please suggest me an edit :)
  • SeanT
    SeanT over 10 years
    That's a good thought, but it's just a standard white UITextView, and the tint color hasn't been changed.
  • Lukasz
    Lukasz almost 10 years
    It also applies to UITextField
  • Apan
    Apan about 9 years
    I've got also situation, when in another view some other developer changed tint colour. I don't know why, when I came back to my view to cursor was hidden. I needed to re-set tint in view will appear programatically.
  • divergio
    divergio over 8 years
    This helped me see the background color issue.
  • Dren
    Dren over 8 years
    Faced that problem with tint color set to default in storyboard. Set another color and default back made cursor appear. Also it is a bit visible due debug view hierarchy session
  • Syeda Zunaira
    Syeda Zunaira over 8 years
    it should be comment.
  • SeanT
    SeanT almost 8 years
    This seemed to be the issue. The tint color was set as "default" which is blue, but I think it was appearing as white, which I've noticed with other controls. I changed it to red in IB and it showed up as red. Then I changed it to blue, not "default" and it finally appeared as blue.
  • Derek Soike
    Derek Soike about 7 years
    If you want the cursor to be a different color from the tint color (buttons), look at my answer posted here: stackoverflow.com/a/42444940/4754881