如何以编程方式检查iPhone上安装的国际键盘?

时间:2011-11-21 11:56:49

标签: iphone objective-c ios

我正在开发一个应用程序,用户可以使用多种语言搜索数据库。 我想知道他的设备上安装了哪些键盘,如果他没有特定的键盘,我可以显示弹出窗口并向他解释如何安装它。 如何获得它?

1 个答案:

答案 0 :(得分:9)

您可以在NSUserDefaults中找到它:

NSDictionary* defaults = [[NSUserDefaults standardUserDefaults] dictionaryRepresentation];

我在iOS模拟器(iOS 5.0)上测试过它。我只安装了美式键盘。默认内容:

AppleITunesStoreItemKinds =     (
        eBook,
        document,
        "software-update",
        booklet,
        "itunes-u",
        newsstand,
        artist,
        podcast,
        "podcast-episode",
        software
    );
    AppleLanguages =     (
        en,
        fr,
        de,
        ja,
        nl,
        it,
        es,
        pt,
        "pt-PT",
        da,
        fi,
        nb,
        sv,
        ko,
        "zh-Hans",
        "zh-Hant",
        ru,
        pl,
        tr,
        uk,
        ar,
        hr,
        cs,
        el,
        he,
        ro,
        sk,
        th,
        id,
        ms,
        "en-GB",
        ca,
        hu,
        vi
    );
    AppleLocale = "en_US";
    NSInterfaceStyle = macintosh;
    NSLanguages =     (
        en,
        fr,
        de,
        ja,
        nl,
        it,
        es,
        pt,
        "pt-PT",
        da,
        fi,
        nb,
        sv,
        ko,
        "zh-Hans",
        "zh-Hant",
        ru,
        pl,
        tr,
        uk,
        ar,
        hr,
        cs,
        el,
        he,
        ro,
        sk,
        th,
        id,
        ms,
        "en-GB",
        ca,
        hu,
        vi
    );
}

然后我添加了俄语键盘,NSUserDefaults的内容变为:

{
    AppleITunesStoreItemKinds =     (
        eBook,
        document,
        "software-update",
        booklet,
        "itunes-u",
        newsstand,
        artist,
        podcast,
        "podcast-episode",
        software
    );
    AppleKeyboards =     (
        "en_US@hw=US;sw=QWERTY",
        "ru_RU@hw=Russian;sw=Russian"
    );
    AppleKeyboardsExpanded = 1;
    AppleLanguages =     (
        en,
        fr,
        de,
        ja,
        nl,
        it,
        es,
        pt,
        "pt-PT",
        da,
        fi,
        nb,
        sv,
        ko,
        "zh-Hans",
        "zh-Hant",
        ru,
        pl,
        tr,
        uk,
        ar,
        hr,
        cs,
        el,
        he,
        ro,
        sk,
        th,
        id,
        ms,
        "en-GB",
        ca,
        hu,
        vi
    );
    AppleLocale = "en_US";
    NSInterfaceStyle = macintosh;
    NSLanguages =     (
        en,
        fr,
        de,
        ja,
        nl,
        it,
        es,
        pt,
        "pt-PT",
        da,
        fi,
        nb,
        sv,
        ko,
        "zh-Hans",
        "zh-Hant",
        ru,
        pl,
        tr,
        uk,
        ar,
        hr,
        cs,
        el,
        he,
        ro,
        sk,
        th,
        id,
        ms,
        "en-GB",
        ca,
        hu,
        vi
    );
}

因此,您需要使用 AppleKeyboards AppleKeyboardsExpanded 键。