Skip to content

Instantly share code, notes, and snippets.

@congbo
Created March 19, 2015 01:45
Show Gist options
  • Save congbo/a773dc9461168ddcc620 to your computer and use it in GitHub Desktop.
Save congbo/a773dc9461168ddcc620 to your computer and use it in GitHub Desktop.
iOS8 UIAlertController弹出框中添加视图(例如日期选择器等等)。相关第三方库:ActionSheetPicker-3.0
UIDatePicker *datePicker = [[UIDatePicker alloc] init];
datePicker.datePickerMode = UIDatePickerModeDateAndTime;
datePicker.minimumDate = [NSDate date];
datePicker.maximumDate = [NSDate dateWithTimeInterval:(24*60*60*2) sinceDate:datePicker.minimumDate];
datePicker.minuteInterval = 10;
datePicker.locale = [[NSLocale alloc] initWithLocaleIdentifier:@"zh_CN"];//设置为中文显示
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"\n\n\n\n\n\n\n\n\n\n\n" message:nil   preferredStyle:UIAlertControllerStyleActionSheet];
[alert.view addSubview:datePicker];
UIAlertAction *ok = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
}];
UIAlertAction *cancel = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
}];
[alert addAction:ok];
[alert addAction:cancel];
[self presentViewController:alert animated:YES completion:^{ }];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment