I am trying to add a date picker to an alert view. I can add the animation to the screen based on a button click and I see a black box but no date picker.
Here is what I have so far....
- (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];
}
I found an example that appears to be working BUT I don't see any dialog or buttons in my alert box, just the date picker itself. Am I missing something here?
- (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];
}