UIAccessibility default language throughout the app

不想你离开。 提交于 2020-01-13 11:21:09

问题


We're working on an app that's localized only in the German language and want to add accessibility feature to it. Since the accessibilityLabels are in German, it would be great to always read it in German, regardless of what the user's default system language is.

I noticed one can set that with the accessibilityLanguage property. But it needs to be set on each control repeatedly.

Is there any way to set the accessibility language once globally for every control in the app?


回答1:


Just found out a way shortly after posting the question! :)

You can set accessibilityLanguage directly on UIApplication in AppDelegate. For example, in application:didFinishLaunchingWithOptions:,

application.accessibilityLanguage = @"de";

And it will be applied to all the controls. Tested on iOS 7.




回答2:


You can make a category on NSObject in a header file like this:

@implementation NSObject (Accessibility)

    - (NSString *)accessibilityLanguage {
        return @"de";
    }

@end

Then consider importing it in you prefix header (.pch file) so you don't have to import it everywhere you need it




回答3:


You can do it by inheritance, and use your customised components which by default would have this value set in the way you want. But probably in the existing project it won't be so easy and quick to apply.



来源:https://stackoverflow.com/questions/21283862/uiaccessibility-default-language-throughout-the-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!