1

在我的应用程序中,我需要在 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]);
}
4

2 回答 2

1

简单:... [UIAlertView..

消息:@"\n\n\n\n\n\n\n\n\n\n\n"

...

也..查看UIAlertView的标题..尝试将“y”从25修改为40..(测试)

dobPicker.frame=CGRectMake(20, 40.0, ...

于 2013-01-09T12:36:25.107 回答
1

Transform ScaleUIAlertView是这样的:

 dAlert.transform = CGAffineTransformScale(dAlert.transform,xScaleHere, yScaleHere); //provide your scaling points sx and sy according to your requirement.
于 2013-01-09T10:34:15.417 回答