我正在尝试将日期选择器添加到警报视图。我可以通过单击按钮将动画添加到屏幕上,我看到一个黑框,但没有日期选择器。
这是我到目前为止所拥有的......
- (IBAction)showDatePicker {
    CGRect frame = CGRectMake(200, self.view.frame.size.height, self.view.frame.size.width, 0);  //CGRectMake(225, 145, 260, 125);
    UIPickerView *datePicker = [[UIPickerView alloc] initWithFrame:frame];
    UIAlertView *showDateAlert = [[UIAlertView alloc]
                                  initWithTitle:@"Enter the Code Date"
                                  message:@"Sample message"
                                  delegate:self
                                  cancelButtonTitle:@"Cancel"
                                  otherButtonTitles:@"Update", nil];
    [self.view addSubview:datePicker];
    [UIView beginAnimations:@"slideIn" context:nil];
    [datePicker setCenter:CGPointMake(datePicker.frame.origin.x, self.view.frame.size.height - datePicker.frame.size.height/2)];
    [UIView commitAnimations];
}
我找到了一个似乎正在工作的示例,但我在警报框中没有看到任何对话框或按钮,只有日期选择器本身。我在这里错过了什么吗?
- (IBAction)showDatePicker {
    CGRect frame = CGRectMake(225, self.view.frame.size.height, self.view.frame.size.width, 125);
    UIDatePicker *datePicker = [[UIDatePicker alloc] initWithFrame:frame];
    datePicker = [[UIDatePicker alloc] init];
    datePicker.datePickerMode = UIDatePickerModeDate;
    [datePicker setDate:[NSDate date]];
    UIAlertView *alert;
    alert = [[UIAlertView alloc]
             initWithTitle:@"Enter the Code Date"
             message:@"Sample message"
             delegate:self
             cancelButtonTitle:@"Cancel"
             otherButtonTitles:@"Update", nil];
    alert.delegate = self;
    [alert addSubview:datePicker];
    [alert show];
}