有谁知道在将 UIDatePicker 添加到 UIView 后是否可以更改它的分钟间隔?是否可以显示和隐藏 2 个不同的日期选择器?单击按钮时,我想将 UIDatePicker 的 minuteInterval 更改为 5 和 30。任何示例代码将不胜感激。
问问题
2105 次
1 回答
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
于 2009-10-07T16:59:27.630 回答