ios 8和iOS 9 适用的uidatepicker

UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"\n\n\n\n\n\n\n\n\n\n\n"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];

posted on 2015-10-13 17:37  🌞Bob  阅读(211)  评论(0编辑  收藏  举报

导航