Я пытаюсь добавить средство выбора даты в представление предупреждений. Я могу добавить анимацию на экран по нажатию кнопки, и я вижу черный ящик, но не выбираю дату.
Вот что у меня пока есть....
- (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];
}