xamarin / xamarin-macios

.NET for iOS, Mac Catalyst, macOS, and tvOS provide open-source bindings of the Apple SDKs for use with .NET managed languages such as C#
Other
2.47k stars 514 forks source link

Missing Accessibility APIs such as accessibilityLabel on UINavigationItem #7325

Open edenwaith opened 5 years ago

edenwaith commented 5 years ago

While adding better accessibility/VoiceOver support for an app, I've noticed a couple of areas where Xamarin is missing some accessibility features in Xamarin for iOS (but are available in Swift).

Steps to Reproduce

accessibilityLabel Description: If one tries to add an accessibilityLabel to a navigation item's title, it results in a compilation error.

Example: this.NavigationItem.Title.AccessibilityLabel = "Some Text";

accessibilityElements Description: The accessibilityElements property is missing for views. This is useful if one wants to put together a specific order that VoiceOver should read elements on a page.

Example: this.View.AccessibilityElements = [button1, button2, button3];

Expected Behavior

The expected behavior is that these accessibility properties should be available on Xamarin for iOS.

Actual Behavior

The actual behavior is that these properties are not available.

Environment

=== Xcode ===
Xcode 11.0
=== Visual Studio Community 2019 for Mac ===

Version 8.3.2 (build 32)
Installation UUID: 5959b6d0-8225-407f-a813-a9c400b9e960
    GTK+ 2.24.23 (Raleigh theme)
    Xamarin.Mac 5.16.1.24 (d16-3 / 08809f5b)

    Package version: 604000208

=== Mono Framework MDK ===

Runtime:
    Mono 6.4.0.208 (2019-06/07c23f2ca43) (64-bit)
    Package version: 604000208

=== NuGet ===

Version: 5.3.0.6192

=== .NET Core SDK ===

SDK: /usr/local/share/dotnet/sdk/3.0.100/Sdks
SDK Versions:
    3.0.100
    2.1.701
    2.1.700
MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/6.4.0/lib/mono/msbuild/Current/bin/Sdks

=== .NET Core Runtime ===

Runtime: /usr/local/share/dotnet/dotnet
Runtime Versions:
    3.0.0
    2.1.13
    2.1.12
    2.1.11

=== Xamarin.Profiler ===

Version: 1.6.12.26
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

=== Updater ===

Version: 11

=== Apple Developer Tools ===

Xcode 11.0 (14936)
Build 11A420a

=== Xamarin.Mac ===

Xamarin.Mac not installed. Can't find /Library/Frameworks/Xamarin.Mac.framework/Versions/Current/Version.

=== Xamarin.iOS ===

Version: 13.2.0.47 (Visual Studio Community)
Hash: c2cbd3480
Branch: d16-3
Build date: 2019-09-30 22:37:32-0400

=== Xamarin Designer ===

Version: 16.3.0.247
Hash: 52eac1a9e
Branch: remotes/origin/d16-3
Build date: 2019-10-03 23:04:28 UTC

=== Xamarin.Android ===

Version: 10.0.3.0 (Visual Studio Community)
Commit: xamarin-android/d16-3/4d45b41
Android SDK: /Users/chad.armstrong/Library/Developer/Xamarin/android-sdk-macosx
    Supported Android versions:
        5.1 (API level 22)
        6.0 (API level 23)
        7.0 (API level 24)
        7.1 (API level 25)
        8.0 (API level 26)
        8.1 (API level 27)

SDK Tools Version: 26.1.1
SDK Platform Tools Version: 29.0.1
SDK Build Tools Version: 29.0.0 rc3

Build Information: 
Mono: mono/mono/2019-06@5608fe0abb3
Java.Interop: xamarin/java.interop/d16-3@5836f58
LibZipSharp: grendello/LibZipSharp/d16-3@71f4a94
LibZip: nih-at/libzip/rel-1-5-1@b95cf3fd
ProGuard: xamarin/proguard/master@905836d
SQLite: xamarin/sqlite/3.27.1@8212a2d
Xamarin.Android Tools: xamarin/xamarin-android-tools/d16-3@cb41333

=== Microsoft Mobile OpenJDK ===

Java SDK: /Users/chad.armstrong/Library/Developer/Xamarin/jdk/microsoft_dist_openjdk_1.8.0.25
1.8.0-25
Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

=== Android SDK Manager ===

Version: 1.4.0.65
Hash: c33b107
Branch: remotes/origin/d16-3
Build date: 2019-09-19 20:42:44 UTC

=== Android Device Manager ===

Version: 1.2.0.115
Hash: 724ea69
Branch: remotes/origin/d16-3
Build date: 2019-09-19 20:43:06 UTC

=== Xamarin Inspector ===

Version: 1.4.3
Hash: db27525
Branch: 1.4-release
Build date: Mon, 09 Jul 2018 21:20:18 GMT
Client compatibility: 1

=== Build Information ===

Release ID: 803020032
Git revision: cac56af22091d80a4c339532595ed90228d87eb0
Build date: 2019-10-04 06:43:01+00
Build branch: release-8.3
Xamarin extensions: 2fc34e1d5c594f52abf0e0e9e14f4945adec6c7f

=== Operating System ===

Mac OS X 10.14.6
Darwin 18.7.0 Darwin Kernel Version 18.7.0
    Tue Aug 20 16:57:14 PDT 2019
    root:xnu-4903.271.2~2/RELEASE_X86_64 x86_64

Build Logs

N/A

Example Project (If Possible)

N/A

chamons commented 5 years ago

So we have accessibilityElements bound I believe as GetAccessibilityElements ().

However, you appear correct that

UINavigationItem is not a subclass of UIAccessibility in our bindings, so we aren't seeing those APIs.

Until we fix that, you should be able to use this work around (manual binding)

edenwaith commented 5 years ago

Thanks for the quick response! I'll try out these suggestions.

MichaelLHerman commented 2 years ago

@chamons For accessibilityElements, UIView and any NSObject should implement the UIAccessibilityContainer protocol but does not.

Screen Shot 2022-02-24 at 5 45 13 PM Screen Shot 2022-02-24 at 5 38 48 PM