ios 8和iOS 9 适用的uidatepicker

UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@" "message:nil preferredStyle:UIAlertControllerStyleActionSheet];

    UIDatePicker *picker = [[UIDatePicker alloc] init];

    [picker setDatePickerMode:UIDatePickerModeDate];

    [alertController.view addSubview:picker];

    [alertController addAction:({

        UIAlertAction *action = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {

            NSLog(@"OK");

            NSLog(@"%@",picker.date);

        }];

        action;

    })];

    UIPopoverPresentationController *popoverController = alertController.popoverPresentationController;

    popoverController.sourceView = sender;

    popoverController.sourceRect = [sender bounds];

    [self presentViewController:alertController  animated:YES completion:nil];

原文地址:https://www.cnblogs.com/isItOk/p/4875296.html