Explore how to open the Accessibility Inspector, and what needs to be changed to connect a project to it.
- [Narrator] First, let's dive into the Accessibility Inspector. In order to do this, you need to have your simulator running and come back to Xcode. Come over to the Xcode menu and then come down and select Open Developer Tool and choose the Accessibility Inspector. Let's go ahead and pull up that simulator again. Now, the Accessibility Inspector first we've got to choose the target. In this case, it's a simulator. And the tool is already working.
If you select this radical, you can choose the different areas that you want to observe. In this case, we're only getting the cells for the table. If we step through it, we can see that the image is selected and then the cell is selected. But we're not getting actual text selected. And that's because we have to do some additional work in order to get the Accessibility Inspector to work with the project. Normally, you could go to the storyboard. Let's go ahead and close this. And select the element and open the Identity Inspector tab.
And make sure that the accessibility is enabled by checking it. This is usually done by default for text fields, not necessarily for images. But for any element that you want to be accessible, you need to make sure that that is checked. Unfortunately, there are problems with Interface Builder in translating all of these type of properties over to the final product. So, in Xcode 8.2, we have to add some code to make sure that this property is set.
This should be fixed in Xcode 8.3 which is currently in beta. So first, let's go ahead and select the custom cell and add these properties. We have this commonInit method, and in here we're going to set some properties to make this work correctly. So in here, we're going to create a method, setAccessibilityProperties. Just make a private func for that. And we're just going to do this for the password value text field or label currently, isAccessibilityElement.
Just set this to true. Now if we compile this and run the tool again and we open up the Accessibility Inspector again, choose our row, we can see already that that text field is now accessible. We see the image again. Now we go to the text field. The whole cell, image, text field. This is all in the inspection panel. If we go to the audit panel, we can start seeing whether there are some problems with accessibility for our application.
And you can see that we have a couple of similar problems with all of these items. The dynamic text is not supported for any of these text fields and the element has no description. If you're confused about what this means, you can click on the question mark and it'll give you a suggestion. In this case, implement the accessibility label. For the dynamic text, it's a little larger topic, so we're going to continue that in the next video.
- Working with the Accessibility Inspector
- Reviewing dynamic text and audit fixes
- Changing device settings within the Inspector
- Using the Memory Debugger
- Using the Thread Sanitizer
- Debugging view hierarchies
- Analyzing a project for memory consumption