无法在TimePicker上访问NSLocale

时间:2019-05-22 10:26:06

标签: angular nativescript

我正在尝试将Nativescript TimePicker设置为24h格式,并在其他线程上找到了一些解决方案,例如How to change TimePicker in NativeScript to show the time in 24-hour format?。唯一的问题是'NSLocale'和'java'无法识别,从而导致我的应用崩溃。如何导入这些属性?

我的代码如下:

onLoaded(args) {
        const timePicker: TimePicker = args.object;
        timePicker.minuteInterval = 15;
        if (isAndroid) {
            timePicker.android.setIs24HourView(java.lang.Boolean.TRUE);
            timePicker.hour = 23;
            timePicker.minute = 59;
        } else if (isIOS) {
            // a bit hacky solution
            // important set the country not the language for locale
            const local = NSLocale.alloc().initWithLocaleIdentifier("NL");
            timePicker.ios.locale = local;
            timePicker.hour = 23;
            timePicker.minute = 59;
        }
    }

0 个答案:

没有答案