Here is my very simple code for creating a UITextView.
UITextView *textView = [[UITextView alloc] initWithFrame:self.view.bounds];
textView.editable = NO;
textView.text = #"Using iOS 3.0 and later, VoiceOver is available to help users with visual impairments use their iOS-based devices. The UI Accessibility programming interface, introduced in iOS 3.0, helps developers make their applications accessible to VoiceOver users. Briefly, VoiceOver describes an application’s user interface and helps users navigate through the application’s views and controls, using speech and sound. Users familiar with VoiceOver in Mac OS X can leverage their experience to help them quickly come up to speed using VoiceOver on their devices.";
[self.view addSubview:textView];
Given that I could not possibly do anything wrong here I am just wondering if this is an expected behaviour or a bug perhaps somebody also faced:
With voiceover enabled I expect the entire text view to be “highlighted” on tap, then its accessibilityLabel to be read to a user and after they double tap, the entire text view’s text to be read.
But what is happening is that a small portion of the text view is highlighted (usually 2 lines), accessibilityLabel is not read, but the first “highlighted" line and the first letter (!) of the second line are read instead and only after a user double taps the entire text is read.
Especially reading the first letter in the second highlighted line confuses me. Plus shouldn’t accessibilityLabel be always read in the beginning?
This looks like a big to me but Apple has always paid so much attention to accessibility, so I’m having doubts if I should report it, may be the meant it to be this way.
Another question: is there a way to achieve the following behaviour (without subleasing UITextView) when voiceover is enabled: user taps UITextView -> accessibilityLabel and the entire text are read?
In case someone else has this problem here is the answer:
textView.accessibilityTraits = UIAccessibilityTraitStaticText;
Combining the other two answers from this post has the desired effect. i.e.
textView.isAccessibilityElement = true
textView.accessibilityTraits = .staticText
Also if you are setting the attributedText property on the UITextView make sure you DO NOT set the accessibilityLabel (on the UITextView). Doing so will cause VoiceOver (Xcode 12.5, iOS 14.4.2) to read the text twice.
textView.isAccessibilityElement = true
This Works
Related
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?
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.
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.
So, Apple has a bug right now where if you type an Emoji into a UITextField, it will shift the text down. In fact, if you type enough emojis and then backspace, it'll shift the text even further down from where it was supposed to be. I confirmed this by trying UITextFields in Twitter, Snapchat and other apps.
Here is a video of my app displaying the bug.
Use this: textField.clipsToBounds = false
It prevents the textField to move when editing. Even when you try to edit it again.
(Tested on iPhone 6, iOS 10.0)
I don't think their would be a way around this, as it just seems that the emoji is changing the margin of the text inside of the UITextField.
My app is getting crash on iOS7
In my app, I have language option. One is English and other is Kannada.
When user selects Kannada, all text turns into Kannada. I have one textview in which I have added static text in Kannada.
When user navigates to that view, the app crashes on iOS7 , while on iOS8 it's working fine.
I am not getting any log for crash. I can only see EXC_BAD_ACCESS (code = 1, ...) . I have tried it by keeping "Enable Zombies" option, still not getting any log in console.
P.S. - I have static text in textview. I am not adding text dynamically. I am just hiding/un-hiding textviews. I can see and read the text in Kannada in my textview in storyboard.
It may be a strange behavior in iOS 7, and it seems to be a bug in the way NSLayoutManager layouts the text for Kannada language. As other answers pointed out, UITextView is build around TextKit since iOS7, and thus uses NSLayoutManager internally to layout text.
Just noticed that in UITextView keyboard comes without change language button, unlike in UITextField. Why Apple removed this button from UITextView keyboard? Is there any way to enable this button? I want people to be able to write notes on any keyboard language added in phone settings.
EDITED: Maybe it will help somebody in the future. Just noticed that I set keyboard type to UIKeyboardTypeAlphabet and this option eliminates language button. Closing this question.
P.S. I have 3 languages enabled in test iPhone.
You are completely wrong. there is no difference in UIKeyboard in iOS whatsoever. It only depends on what keyboard types you use.
UIKeyboardTypeDefault and UIKeyboardTypeEmailAddress and UIKeyboardTypeTwitter all have those.
You set it like this:
txtField.keyboardType = UIKeyboardTypeTwitter;
UIKeyboardTypeDefault is obviously the default one for any UITextView or UITextField in iOS.
For anyone have this problem even when using UIKeyboardTypeDefault on a UITextView, go into the storyboard and make sure "Secure Text Entry" is unchecked. After unchecking this, the keyboard selector will return as well as the quick type keyboard.
How does one prevent “…misspelled” from being spoken by VoiceOver on a text field? Setting autocorrectionType to UITextAutocorrectionTypeNo doesn’t seem to make a difference.
If the iOS user types a misspelled word followed by a space or punctuation, Voiceover speaks the word followed by, “misspelled.” I want to be able to disable this behavior on a specific text field.
I would expect you to set spellCheckingType = UITextSpellCheckingTypeNo to get this behavior rather than autocorrectionType. Does that not resolve it?