Does anyone know if it's possible to change the minute interval of a UIDatePicker after it's been added to a UIView? Is it possible to show and hide 2 different datePickers? I want change the minuteInterval of the UIDatePicker to 5 and 30 when I click a button. Any sample code would be appreciated.
A:
Yes, everything you asked is possible... here's how:
#import "DateStuffAppDelegate.h"
@implementation DateStuffAppDelegate
@synthesize window;
- (void)applicationDidFinishLaunching:(UIApplication *)application {
d = [[[UIDatePicker alloc] init] retain];
d.frame = CGRectMake(0, 0, d.frame.size.width, d.frame.size.height);
d.datePickerMode = UIDatePickerModeTime;
d.countDownDuration = 10.0;
d.minuteInterval = 1;
[window addSubview: d];
d1 = [[[UIDatePicker alloc] init] retain];
d1.frame = CGRectMake(0, d.frame.size.height, d1.frame.size.width, d1.frame.size.height);
d1.datePickerMode = UIDatePickerModeTime;
d1.countDownDuration = 10.0;
d1.minuteInterval = 1;
[window addSubview: d1];
[window makeKeyAndVisible];
}
- (IBAction)doStuff
{
d.minuteInterval = 5;
d1.hidden = !d1.hidden;
}
- (void)dealloc {
[window release];
[super dealloc];
}
@end
luvieere
2009-10-07 16:59:27