0

iOS - swift 3.0 : I am developing an iOS app with English and Arabic languages. In my password text field, which is in "secure text entry" mode, when I change the text input language of the keyboard from English to Arabic, it is still showing the caps lock indicator. I am not able to figure out any solutions for this strange issue. Pls help me out. Thanks in advance.

Note: I am not able to even reproduce this often, but my client reports this bug. I am totally clueless. Looks like iOS bug?

ABHILASH P
  • 105
  • 1
  • 10
  • Since the spam answer was thankfully removed (wow, that was quick), a quick answer here: I'm sorry, I don't have a solution. I've never done anything specific with the capslock indicator (and doubt you can do much?) or with arabic localizations in general. Maybe one clarifying question for others though: I take it an arabic keyboard does not have a capslock/shift button at all? Is it maybe still active from users having it pressed while still showing an english keyboard? – Gero Aug 02 '17 at 12:33
  • @Gero ...u are absolutely right . The caps lock indicator comes only when it was enabled while in English keyboard and then u go to Arabic keyboard. But apple should have handled that right? I mean, the caps lock indicator should be hidden as soon as the keyboard changes to Arabic. – ABHILASH P Aug 02 '17 at 12:55
  • @Gero....but its just a speculation that , the caps lock indicator comes when it was enabled while in English keyboard and then u go to Arabic keyboard – ABHILASH P Aug 02 '17 at 13:02

2 Answers2

0

Okay, assuming that the Arabic keyboard basically has no shift key (and further assuming that having pressed shift before on its English counterpart doesn't actually modify the input, i.e. it's just a graphical glitch) that sounds like a bug on Apple's part.

According to this answer (which is dated, but I assume still valid) you can't really change anything about the keyboard programmatically in this sense. I.e. you can't press a button like shift in code.

If it's really just a graphical issue and you can figure out when exactly the icon should disappear, you can work around it by overlaying your own image over the button (e.g. a white square to hide it), like so. I don't know which event or delegate method would immediately happen before the image needs to be set, though, you will have to figure this out with your users.

I'd furthermore suggest filing a rdar for Apple if it's really just a graphical issue.

Gero
  • 4,394
  • 20
  • 36
  • @Gero....really appreciate your answer. But the problem in showing the image is that, it will hide the characters that are going to be entered by the user. Because the moment keyboard changes to Arabic, I make the text to be entered from the right side of the UITextField(right to left), ; hence if I am going to put an image above the caps lock indicator icon (which comes at the right side of the text field), it will hide the rightmost characters(in Arabic) to be entered by the user. So this is the huge issue because of which I am not able to make my APP live. Anyway will file a radar for Apple – ABHILASH P Aug 02 '17 at 13:24
  • So the indicator vanishes as soon as text appears? or is it above/below the text? If it's the former, just remove the image as soon as the text is updated (relying on the delegate method for that), if it's the latter, you're probably out of luck. :( – Gero Aug 02 '17 at 13:29
  • @Gero.....the indicator remains as it is. It won't go when user starts typing Arabic. Thats where is the problem. And this is reproduced by my client. Even I am not able to reproduce this bug. My whole App is struck because of this issue. Can u please tell me one thing, that , if I file a radar with apple , will they consider it, because I don't have a big profile. – ABHILASH P Aug 02 '17 at 14:12
  • Radar: No idea, they don't comment on this AFAIK. You might additionally want to post in apple's dev forums, sometimes a staff member answers. In general I'm in the same boat though, just a small town app dev. :) Besides, compared to Apple, most devs are... "Vanishing": What I meant was, is the icon harshly obstructing readability, i.e. are the Arabic letters typed *on* it or something, or is it at least properly _next to_ the letters (as it is with the English letters, even if you "reach" the icon, the text does not get printed "onto" it) – Gero Aug 02 '17 at 14:41
  • Okay, that is unfortunate, but definitely sounds like a bug. Say what you want about Apple, but visual inconsistencies like that are never done intentionally by them, everything usually looks just "smooth", so this strongly suggest it's not intended behavior. Sadly that means there's nothing you can do but report a bug (I suggest bug reporter, rdar and dev forum post?). :( – Gero Aug 02 '17 at 14:57
  • @Gero.....I will try to report this bug. Will update here if I get any solution.Really appreciate your help – ABHILASH P Aug 02 '17 at 15:23
0

Finally, I came up with a solution to hide the caps lock indicator of the textfield when it is in secureTextEntry mode.

//-------To hide caps lock indicator------//

        let v = UIView(frame: CGRect(x: 0, y: 0, width: 0, height: 0))
        self.passwordTextField.rightView = v

//----------------------------------------//   

Basically, the caps lock indicator is presented on the right view of the UITextFiled by default, when the textfield is in secureTextEntry mode. By assigning a view with zero dimension to the right view of the textfield , it just overrides that view with the new view(which has zero dimension) , hence the caps lock indicator never appears there after.

Forge
  • 6,538
  • 6
  • 44
  • 64
ABHILASH P
  • 105
  • 1
  • 10