有人知道在UIDatePicker被添加到UIView后是否可以更改UIDatePicker的分钟间隔?是否可以显示和隐藏2个不同的datePickers?我想在单击按钮时将UIDatePicker的minuteInterval更改为5和30。任何示例代码都将受到赞赏。
答案 0 :(得分:1)
是的,您提出的所有问题都可能......以下是:
#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