UiPicker上的小尺寸问题,在警报视图中(警报视图的高度问题)

时间:2013-01-09 10:22:03

标签: iphone objective-c datepicker uipickerview uialertview

在我的应用中,我需要在UIAlert视图上有一个日期选择器

我是按照Date Picker in Alert View

实施的

但是当我在警报视图中使用此日期选择器时,是警报视图中的一些高度问题我试图为警报视图设置框架,但它没有设置要做什么?

enter image description here

我的代码:

-(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]);
}

2 个答案:

答案 0 :(得分:1)

Transform Scale您的UIAlertView就像这样:

 dAlert.transform = CGAffineTransformScale(dAlert.transform,xScaleHere, yScaleHere); //provide your scaling points sx and sy according to your requirement.

答案 1 :(得分:1)

简单:... [UIAlertView ..

  

消息:@ “\ n \ n \ n \ n \ n \ n \ n \ n \ n \ n \ n” 个

...

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

  

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