在我的应用程序中,我需要在 UIAlert 视图上有一个日期选择器
但是,当我在警报视图中使用此日期选择器时,警报视图中存在一些高度问题,我尝试为警报视图设置框架,但它没有设置要做什么?
我的代码:
-(void)SetDate
{
dobPicker = [[UIDatePicker alloc] init];
dobPicker.frame=CGRectMake(20, 25.0, 240.0, 150.0);
dobPicker.datePickerMode = UIDatePickerModeDateAndTime;
[dobPicker setDate:[NSDate date]];
UIAlertView *dAlert = [[UIAlertView alloc] initWithTitle:@"Set Date" message:@"nnnnnnn" delegate:self cancelButtonTitle:@"Set Current Date" otherButtonTitles:@"Set New Date", nil];
dAlert.frame=CGRectMake(10, 10.0, 300.0, 400.0);
dAlert.delegate = self;
[dAlert addSubview:dobPicker];
[dAlert show];
[dAlert release];
}
- (void) alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex
{
NSDate *date = [dobPicker date];
NSDateFormatter* dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
[dateFormatter setDateFormat:(NSString*) @"yyyy-MM-dd"];
NSLog(@"-------------------------- %@", [dateFormatter stringFromDate:date]);
}