I am testing my iOS application in terms of accessibility and I am trying to reduce as many warnings as possible. Some elements, like images, I want to omit from the Voice Over, so I mark them as not accessible. However, in the Accessibility Inspector, I get the warning
"Potentially inaccessible text" - even though it is an image marked as not accessible.
Is there a way to mark some elements as "ignored" for the Accessibility Inspector such that they are not reported anymore?
Accessibility Inspector printscreen:
It is not an answer itself, but maybe you could do something similar.
I had the same issue. Setting the isAccessibilityElement to false should've done the trick but it seems to be a bug.
In my case what solved the issue was to make the container of the image an accessibility element and the warning disappeared. Doing this the inner items are going to be ignored and I think the accessibility inspector is not going to take that into account. But the isAccessibilityElement should do the same but for some reason it isn't. ;)
Related
Setting showsTouchWhenHighlighted, e.g. via the IB option "Shows Touch On Highlight," on a button without a title will alter the VoiceOver description. After reading the accessibility label, VoiceOver beeps and announces a description of the image. Is there a way to disable this behavior?
Setting the accessibilityContainerType value to UIAccessibilityContainerTypeSemanticGroup works and that's great 👏 but I'm not sure that
this is the goal of this element.
Even if a button my be seen as a container, I understood this instance property dealt with
data-based containers rather. 🤔
I looked into your problem that arouse my curiosity and couldn't find out an appropriate solution with the Apple API unfortunately.
First, I thought that this solution may help but it didn't work as you mentioned in your comment... thanks. 😉
Apparently, when the showsTouchWhenHighlighted property is used, there's an added view inside the button that renders the glow touch ⟹ this is a UIButtonBarPressedIndicator image you can detect thanks to the Debug Hierarchy in Xcode for instance. 👍
This new image seems to put the default value of the accessibility trait property of your button image even if you have already changed it programmatically. 🤯
So, in order to avoid VoiceOver from using the screen recognition and reading out some useless information, I made something very ugly but efficient to reach your goal in the viewDidAppear for instance (see the 'basic operations' sheet of this link):
myButton.subviews.forEach{$0.accessibilityTraits = .none}
Bad hack due to a native problem of implementation or a simple line of code that anyone can understand, this solution removes every possible VoiceOver screen recognition from the button 🥳... and I'm still interested if you can explain a little bit the reason why your solution works, please. 😉
Set accessibilityContainerType = UIAccessibilityContainerTypeSemanticGroup.
I'm wondering if there is a way to check the hints using Accessibility Inspector? Or any other way on iOS to debug the accessibility viewing the hints? Thanks!
As far as I know, accessibility hints are not displayed in Accessibility Inspector. What I tend to do instead is run the app and then launch layout inspector. After it loads you can select the view you are interested in and see accessibility labels, traits, hints, etc.
I am not sure why hints are not displayed in AI.
I recently used this "iOS Color Picker" (the top response) from StackOverflow into my project. It's absolutely fantastic, and draws straight into Interface Builder - however, it also seems to cause Xcode to rebuild constantly.
As soon as I type one single character, Xcode rebuilds the entire project and it's getting incredibly tedious. All the information I could find on the matter tells me to turn off "Live Issues" under the Xcode prefs - but as a relative beginner to coding, I rely heavily on being able to see errors as they appear.
My question is: is there any way to turn off this constant rebuilding WITHOUT disabling "live issues"? (either by altering the iOS Color Picker code, or some other option in Xcode itself?)
Thanks!
It is caused by the IB_DESIGNABLE definitions in the source header files. Probably it makes problem only if the header file containing IB_DESIGNABLE is included (even implicitly) to the source file you are currently editing.
I did not find a definitive solution how to disable IB_DESIGNABLE and thus compiling the storyboard and the source files continuously. I would appreciate an Xcode flag to disable this temporarily. I tried also surrounding the IB_DESIGNABLE with #ifdef macros but they are considered even if the #ifdef evaluates to false. Commenting out one by one the IB_DESIGNABLE helps but it is not a feasible solution with many IB_DESIGNABLEs.
Update
I finally found a quick way to avoid this annoying behavior. Having the storyboard opened in the active window, disable "Automatically Refresh Views" from the Editor menu. This will stop updating the views in the storyboard editor that use your custom code and thus speed up your development significantly. When you need again the just-in-time compiling to have a visual preview of your custom code, enable this option again (it seems you also have to re-open your storyboard to make it working again).
You may wish to add a key binding to the command, such as command-option-control-A, to easily toggle the behavior on/off. To add a key binding in Xcode, touch command-comma for preferences, choose the Key Bindings tab, use the search bar to find the command, then double-click on the right area to add your desired keystroke.
"Leave it off" approach
Alternately turn "Automatically Refresh Views" off, and never turn it on.
Make a convenient keystroke for "Refresh all views", say command-option-shift-R
As you work, just touch command-option-shift-R from time to time, or as needed. It's generally only necessary to touch command-option-shift-R as you work on the storyboard.
I wanted to use the Accessibility Inspector to verify all the accessibility identifiers in my app running in the simulator (iOS 9.2).
Accessibility Inspector is able to return multiple accessibility fields but not the identifiers.
Any idea why and how I could see them ?
There is actually a way, and Chris Prince missed out on explaining how to get to it.
You start off by bringing up the inspector.
The bar above basically focuses the inspector to whatever process you need to inspect. In our case it should be simulator.
Edit: as pointed out by Dallas, you have to click on the left half revealing the possible targets. Click on the Simulator to have the Inspector target it.
Something to note that it seems that simulators have their own information to show. Focusing on the simulator will automatically add in the identifier and show the proper accessibility information.
voila!
I have only recently started using accessibility features, but at least as of Xcode9.1b2, accessibility identifiers are visible within the Accessibility Inspector. See for example:
You will never be able to (without changes from Apple) see this property in Accessibility Inspector, because it isn't really used for accessibility. That it is associated with accessibility is a misnomer, related to accessibility API's generic value in identifying elements for automated testing using UI Automation, because accessibility information is available cross process. To get this info you could cast UI elements to UIAElements and access the name property, and pass this to NSLog.
EDIT: Yep, look at Saleh's answer. Apple added this at some point! Be wary about relying on this, Accessibility Inspector has been very buggy and unstable for me recently. But that answer would be the accepted answer if you're not answering this 3 years ago!
Xcode is so flaky, sometimes the Accessibility Label or Identifier will not show in the Accessibility Inspector. When this happens I just
Set the Label and/or Identifier
Edit the display text under the Attribute Inspector, the value right under the Text selector. After doing a build I will change the value back.
Or add a IBOutlet then delete it.
If you change just the Label or Identifier Xcode does not detect it.
Make sure you have XCode opened in the background
(even though you are using Accessibility Inspector standalone app)
I have a Nib view that my coworker has created with working autolayout constraints. When he resizes the view in interface builder the constraints are applied and the view is shown correctly.
When I do the same thing on my computer the constraints are not applied. We have compared the settings and view options but we can't see any differences.
The feature is called "live autoresizing" and its failure may be a bug. See this question where other people had a similar problem. In fact, just now it was working for me, but when I turned it off and on again in the Editor menu, it no longer did, even after restarting.
Setting up a keyboard shortcut for Update Frames in the Xcode preferences -> key bindings could help speed things up a lot. In my case I found it listed twice and one of them had a shortcut already assigned, but it didn't work. Ah, Xcode.
You can go to bugreport.apple.com and file a radar, but if you're going to do that see this page first.
Check if use autolayout and use size classes is enabled in the file inpector in the .xib file.