2009-09-24 11 views
0

Est-ce que quelqu'un sait s'il est possible de changer l'intervalle des minutes d'un UIDatePicker après qu'il a été ajouté à un UIView? Est-il possible d'afficher et de masquer 2 datesPickers différentes? Je veux changer l'intervalle de minute de l'UIDatePicker à 5 et 30 quand je clique sur un bouton. N'importe quel code d'échantillon serait apprécié.UIDatePicker questions concernant l'affichage

Répondre

1

Oui, tout ce que vous avez demandé est possible ... voici comment:

 

#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