iPhone Timer Picker - iphone

Is it possible to make this go as granular as seconds without having to write a custom picker?

You have to write a custom picker to enter seconds.
UIDatePicker is constrained to the following Date Picker Modes as defined in UIDatePicker, none of which displays seconds:
typedef enum {
UIDatePickerModeTime,
UIDatePickerModeDate,
UIDatePickerModeDateAndTime,
UIDatePickerModeCountDownTimer
} UIDatePickerMode;
Cheers, niels

Related

Display Only Hours In UIDatePicker

I have the following code that sets up a UIDatePicker to show only time. I have two of these UIDatePickers displaying and I want to use them to allow the user to select a time range e.g. between 7 am and 5 pm.
UIDatePicker *datePicker=[[UIDatePicker alloc]init];
datePicker.frame=CGRectMake(-20, 0, 180, 200);
datePicker.datePickerMode = UIDatePickerModeTime;
[datePicker setMinuteInterval:0];
[datePicker setTag:1];
How can I set up the UIDatePicker so that it only shows hours and no minutes?
UIDatePicker isn’t that customizable. You’ll need to set up your own UIPickerView containing the time range you’re looking for. To fit the user’s date/time settings, you should use NSDateComponents and NSDateFormatter to get names for the hours that you need.
This does not take localization into account and will be wrong in practically any other language.
The best advice would be to file a radar at Apple requesting more customization of this API.

Show Specific dates in Tapku library Calender

I have implemented Tapku Library calender in my olympic based iphone app. I want to enable a set of dates(Olympic dates) on it, so that user can only select those dates.
Don't know how to implement it in my app.
You need to use following delegate method for get selected date
- (void)calendarMonthView:(TKCalendarMonthView *)monthView didSelectDate:(NSDate *)d
{
NSLog(#"calendarMonthView didSelectDate");
}

iphone application linking calendar with textfield

In my application i want to textField where user can put date. Now for taking date i need calendar so that user select date from it and it automatically fill into textField.
What would be the best approach to do so.
Thanks
UIDatePicker will allow the user to easily select the date.
uidatepicker and take the value changed
I built a fancy UITextField class that set up a UIDatePicker as its inputView. The main value to this is that, when the user taps into the text field, the date picker is brought up where the keyboard would normally be.
UIDatePicker *input = [[UIDatePicker alloc] init];
[input addTarget:self action:#selector(update:) forControlEvents:UIControlEventValueChanged];
(UITextField *)myTextField.inputView = input;
[input release];
Then, in the -[update:] method, use an NSDateFormatter to set the text in the textfield.

iPhone Datepicker plays 'tick' sound

Does any of you know what event I can tap into on the DatePicker when the wheel moves.
I want to play a sound (got sound code) as the wheel spin. Just like the timer set picker in Apple's clock app.
All that is there is a single event for ValueChanges which only fires once, at the end of a wheel spin.
Thanks in advance
I'm not sure this is possible, as the sounds seem to be linked to the Keyboard Clicks in the phone settings. Maybe someone else has a solution, but it doesn't seem to be documented anywhere.
There is an undocumented method for doing this:
Disable UIPickerView sound
#import <UIKit/UIKit.h>
#interface SilentUIPickerView: UIPickerView
{ }
- (void) setSoundsEnabled: (BOOL) enabled;
#end
use this subclass and call [view setSoundsEnabled: NO]
the reason behind this is when your controller is load the datepickr is scrolling so in view did load
write this code.
NSDate *d = [[NSDate alloc] init];
[objDatePicker setDate:d animated:NO];

Time Touch Events Take in iPhone SDK

I am wondering how I would go about measuring the time in between touches inside a view in the iPhone SDK. I know that the first event triggered is touchesBegan: and then the last one triggered is touchesEnded:, however I just don't know how I would go about measuring the time that the user has touched the view for. For instance, if they keep their finder in the view for 2 seconds, it will automatically trigger function twoSeconds: or something like that.
Thanks for any help!
Use [NSDate date] to get the current date and time. Store it in touchesBegan:, and fetch the duration in touchesEnded: as this
NSTimeInterval duration = [[NSDate date] timeIntervalSinceDate:beganDate];
You will now have the duration between the events measured in seconds in length.