Accessibility Identifier not visible in Accessibility Inspector with iOS Simulator - ios

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)

Related

Mark accessibility elements as "ignored" by Accesibility Inspector

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. ;)

How can I check hints in Accessibility Inspector?

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.

Nib view in Xcode Interface builder does not apply autolayout constraints

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.

Accessibility label in UIAutomation

Is it possible to avoid accessibility labels when using UIAutomation?
If you want it to be seen by UIAutomation but not by applications like VoiceOver, you should use accessibilityIdentifier property of UIAccessibilityIdentification Protocol.
It allows you to set the value later seen trough UIAElement.name
Normally when not set, name is copied from the label.
But when the second is seen by VoiceOver the first one is not.
This is available in iOS 5.0 and later.
You can as well look at the UIAccessibility Protocol it has some more nice tricks.
Unless your app is very simple*, it is not. UIAutomation relies on accessibility labels.
Even if you could do this, you would not save any effort, you would still need to provide some way for UIAutomation to identify your UI elements.
* the simple case would be where there is only one distinct UIView subclass on screen at once. In this case, UIAutomation will generate anonymous references to the unanamed element which allow your scripts to hobble along. It is very brittle though.
In general, you have two ways to access an element : by its label or by its rank.
Example :
target.frontMostApp().mainWindow().tableViews()[0]
or target.frontMostApp().mainWindow().tableViews()["Contents"]
You can choose which one you want to use in UIAutomation by clicking on the element in the script editor.

Why does the iOS Simulator show only a blank view/window?

I'm new to iOS development. I used the Interface Builder to add text fields and buttons to my view. When I run the app, the iOS Simulator only shows an empty beige screen. What am I missing? The console doesn't show any error.
It is because you have not connected your view to your File's Owner.
To do this Right Click on the View, Control Click on the Oultlet of your View and drag it to the File Owner.
This shall solve your problem.
Cheers
I reckon it's because you have AutoLayout turned on in your storyboard, but haven't set any constraints.
Follow my instructions in the following article, to confirm if this is true.
AutoLayout problem
Basically, with XCode 6, if you have AutoLayout turned on, you must set constraints on every single control... otherwise your screens will look fine within XCode, but the controls in your screen could (and will) end up anywhere and in any size when the app is run.
It's like designing a beautiful webpage, then displaying it in an angry, drunk, disorientated browser.
XCode is really unintuitive, and unhelpful for beginners... but once you learn the rules of AutoLayout (along with its many quirks), it's reasonable useful.

Resources