0

UIView に追加された後に UIDatePicker の分間隔を変更できるかどうかは誰にもわかりませんか? 2 つの異なる datePickers を表示および非表示にすることは可能ですか? ボタンをクリックしたときに UIDatePicker の minuteInterval を 5 と 30 に変更したい。サンプルコードをいただければ幸いです。

4

1 に答える 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 に答える