Codename One showNativePicker is not displaying - picker

I have searched for simple examples of using a picker without any luck.
I would like to have my picker pull from a set of strings for the user to choose from, but I can not seem to even get the following to display.
Long now = new Date().getTime();
Date date = (Date) Display.getInstance().showNativePicker(Display.PICKER_TYPE_DATE, cal, now, null);
edit : added code block

You should use the Picker class and not that API directly.
Native picker is only supported for some specific types of picker and only on physical Android/iOS devices. The Picker class seamlessly shows a Spinner instead when unavailable.
To check if the native picker is supported use Display.isNativePickerTypeSupported.

Related

ionic datetime picker opentable style

I am using ionic to build a mobile application and I want to use a datetime picker like to "OpenTable" app. I inserted the image of the control.
Is there some kind of library to make my datetime picker similar to that ? Or is there easier way to build that ?

Swift Date Picker object enable/disable

I want to disable a date picker object in swift 2. I already do this with UI objects and it works fine. E.g.:
dailyNotificationSwitch.enabled = false
When I try this with a date picker it does not have the same effect. Users can still use the date picker. When I disable a switch users can not use the button until it is enabled again.
Here my line for the date picker:
datePicker.enabled = false
Any suggestion what I am doing wrong or an explanation why I can't disable a date picker?
BR
Nikolay

Dynamic font change and font color changes in Iphone application

I have an application which get the settings values such as font color style etc from API.
The user can edit those values from web view and those need to be reflected in the APP.
Can any one suggest the best method to integrate with the app.??
My suggestion:
Use a convenient JSON framework, such as stig's JSON-Framework.
Get the info from the server in JSON format (obviously), via NSURLConnection (documentation here).
Assign the properties of your UI elements such as textColor, font etc.
Seems doable - but based on the given information I would perhaps recommend to let your users do that from within the app. It would be much more intuitive.
EDIT: More specific implementation info.
You can simply use global variables. E.g., make a class Formats which stores all the values you need, fetching and parsing them as necessary (lazily). Then, when you need certain formatting, just use code like
Formats *format = [[[Formats alloc] init] autorelease]; // or pass a reference
myNameTextField.textColor = [format textColorForNames];

UIDatePicker - Problem Localizing

I've created a UIDatePicker in my app and I also have support for several languages. My UIDatePicker is created in Interface Builder, and I have created a seperate localization XIB so I can customize my UIDatePicker.
Setting the "Locale" option in IB appears to do nothing. Attempting to change my DatePicker programatically with Locale and NSCalender also do nothing via the following code:
NSLocale * locale = [[NSLocale alloc] initWithLocaleIdentifier:#"es_ES"];
datePicker.locale = locale;
datePicker.calender = [locale objectForKey:NSLocaleCalender];
This results in an english picker.
Here's the really weird thing though. The word for "Today" is translated. As seen in the attached screenshot. (OK I'm not allowed to post images. But imagine a Date & Time picker with "May" in English and "Today" written "Ajourd'hui".
Based on what I've read, adding the UIDatePicker programatically doesn't seem to help much.
After further investigation, this is actually not handled by the language setting of the iPhone. The UIDatePicker is automatically localized based on the "Region Format" setting and not the language. This is odd because the dates are localized, so you would think the localization of the picker would be linked to the iDevice's language not the Region Format.
Anyway, to simulate the localized DatePicker in the Simulator:
Exit your app, go to Settings.
Select General
Select International
Select the bottom option, Region Format.
Change to the desired region.
Relaunch your app and see the new UI Picker!
As of iOS 6 UIDatePicker no longer looks at the device's settings for locale information. You must may set the NSLocale manually or it will use the default locale.
See this answer: https://stackoverflow.com/a/12975871/1128896
A simple solution:
datePicker.locale = [NSLocale currentLocale];
Updated
While the locale can now be set on UIDatePicker, by default it is set to 'Default' instead of any particular language. 'Default' will check the device's locale, and set itself to that. (see Dave DeLong's comment below). Therefore, most new projects shouldn't be impacted by this change.
If you are working with older projects, migrating to iOS 6, you may find that the UIDatePickers which are created in xibs have their locale defaulted to 'English' or another language instead of 'Default'. (I've found all of my old projects, pre iOS6, followed this behavior). To fix this, simply change the locale to 'Default' in IB.
What I am given to understand is that the UIDatePicker automatically shows in the locale the device is set as. I'm not sure how to override it, but it seems like you probably shouldn't override it.
From my experience the "Today" is following the settings you have in your info.plist. For some reasons they've forgotten to adapt this.
You can set the Date picker localization like this(I am using a language manager) in code.
func configurePickers() {
let languageID = AppLanguageManager.shared.currentLanguage
let loc = Locale(identifier: languageID)
[outgoingPicker, backPicker].forEach {
$0?.locale = loc
$0?.minimumDate = Date()
}
}
From interface builder, you also can set date picker localization:

How To Call/Create iPhone Calendar In A User Application

I would like to know whether we can create a calendar using NSCalender and show it in our dedicated application. We can create a NSCalender object by
****NSCalendar *japaneseCalendar = [[NSCalendar alloc] initWithCalendarIdentifier : NSJapaneseCalendar];****
But how can we show this calender in out application. Is there any way to show the default calander in our application when a user click a button.
Please please guide me, i am hanging here for last few days.
Thank You
Rahul
NSCalendar has nothing to with the Calendar app on the iPhone, it's simply a class used to represent a calendar for whatever reason you need one.
I'm not sure that this can be done on the iPhone from within an app.
-
After re-reading your question, I think I misunderstood what you were asking.
If you want to display some kind of calendar view within the app using that particular calendar, you'll have to create you own view and draw the calendar into it.
You may be able to find some code on the internet to accomplish this already.