18

Simply creating a UITextField in ios7 SDK but when I enter some input, text is shown UItextField but cursor isn't.

Any clue about what can be the problem?

General Grievance
  • 4,555
  • 31
  • 31
  • 45
Kanhaiya Sharma
  • 1,040
  • 8
  • 20

4 Answers4

52

Change the tintColor of the UITextField with a cursor

  [mobileTextField setTintColor:[UIColor blueColor]];

if you are use the XIb please set the tin color of UITextField

enter image description here

Note :- This is working on IOS 7+

Deepesh
  • 8,065
  • 3
  • 28
  • 45
  • This worked, but I still don't understand why the default tint setting doesn't work. – bickster Oct 10 '14 at 15:47
  • Every day I hate Apple a little bit more for providing such a SDK... Much more fun doing Android apps. Thanks for this anyway! – Benjamin Piette Oct 16 '14 at 16:55
  • @bickster the issue is when you set the tint color to clear color or white color for your main view. Try changing that first. Then the textfields will be changed as well. – Sudhin Davis Jan 28 '16 at 05:39
4

As @Deepesh said, it's a matter of choosing the proper tint color. However it was not enough in my case since I am creating the UITextField programmatically and for some reason this setting is ignored.

- (UITextField *)textfieldPhotoTitle
{
    if (_textfieldPhotoTitle) {
        return _textfieldPhotoTitle;
    }

    _textfieldPhotoTitle = [[UITextField alloc] init];
    _textfieldPhotoTitle.placeholder = NSLocalizedString(@"PHOTO_UPLOAD_PHOTO_TITLE_PLACEHOLDER", @"");
    _textfieldPhotoTitle.keyboardType = UIKeyboardTypeASCIICapable;
    _textfieldPhotoTitle.layoutMinSize = CGSizeMake(0, 40);
    _textfieldPhotoTitle.layoutInsets = UIEdgeInsetsMake(11, 15, 9, 0);
    _textfieldPhotoTitle.tintColor = UIColor.blueColor; // IGNORED. NOT WORKING!!
    _textfieldPhotoTitle.delegate = self;

    return _textfieldPhotoTitle;
}

On the other hand, setting the color inside the textFieldDidBeginEditing did solve the issue:

- (void)textFieldDidBeginEditing:(UITextField *)textField
{
    textField.tintColor = UIColor.blueColor;
}

Working in iOS8.

Mr Spiegel
  • 66
  • 5
1

The issue is related to the tintColor of the UITextField.

The problem can be solved by setting the tintColor of the mainView holding the UITextField to default. Since this will affect all subviews in XCode 7. Anyway this solved my problem and working fine from ios 7 and above.

Sudhin Davis
  • 2,010
  • 13
  • 18
0

Same issue coming for me when I had using UITextField. The scenario is when ever tapped on textfield, immediately remove the same view.

So, this issue resolved when I have used [view endEditing:YES];

Hope this will help you.