Skip to content

TTMSFMXNativeUIDatePicker

Usage

The TMSFMXNativeUIDatePicker class implements an object that uses multiple rotating wheels to allow users to select dates and times. iPhone examples of a date picker are the Timer and Alarm (Set Alarm) panes of the Clock application. You may also use a date picker as a countdown timer.

Published Properties

Property name Description
CountDownDuration This property (in seconds) is only used to display a number when the Mode is set to dpmDatePickerModeCountDownTimer. It does not actually count down. This requires manual implementation.
DateTime The datetime displayed by the DatePicker.
MaximumDateTime The maximum datetime that a DatePicker can show.
MinimumDateTime The minimum datetime that a DatePicker can show.
MinuteInterval The interval at which the DatePicker should display minutes.
Mode The value of this property indicates the mode of a DatePicker. It determines whether the DatePicker allows selection of a date, a time, both date and time, or a countdown time. The default mode is dpmDatePickerModeDateAndTime.
Visible Shows / hides the DatePicker.

Public Properties

Property name Description
DatePicker Returns a reference to the native iOS UIDatePicker.

Methods

Methods name Description
NSDateToDate(ADateTime: NSDate): TDateTime; Returns a TDateTime from a native iOS NSDate instance.

Events

Events name Description
OnValueChanged Event called when a date / value has changed.

Countdown timer

With the Mode property set to dpmDatePickerModeCountDownTimer the DatePicker can be set to a countdown timer. Additionally the amount of seconds to countdown from needs to be set with the CountDownDuration property.

In the sample below, the DatePicker is set to a countdown duration of 60 seconds. The user can select an amount of countdown seconds from which to start from.

TMSFMXNativeUIDatePicker1.Mode := dpmDatePickerModeCountDownTimerl;
TMSFMXNativeUIDatePicker1.CountDownDuration := 60;
FDuration := 60;
The OnValueChanged event is triggered when the user changes the value on the countdown wheel.
procedure TForm1.TMSFMXNativeUIDatePicker1ValueChanged(ASender: TObject;
  ADateTime: TDateTime);
begin
  FDuration := TMSFMXNativeUIDatePicker1.CountDownDuration;
end;
To actually use it as a timer, a TTimer component is used to start counting down from the value chosen by the user. The timer can be used to, as an example, update a label.
procedure TForm1.Timer1Timer(Sender: TObject);
begin
  FDuration := FDuration - 1;
  TMSFMXNativeUILabel1.Text := 'Seconds left = ' + floattostr(FDuration);
end;