iOS8 UIAlertController弹出框中添加视图(例如日期选择器等等)

UIDatePicker *datePicker = [[UIDatePicker alloc] init]; datePicker.datePickerMode = UIDatePickerModeDate;spa

UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"\n\n\n\n\n\n\n\n\n\n\n\n" message:nil   preferredStyle:UIAlertControllerStyleActionSheet];orm

[alert.view addSubview:datePicker];对象

UIAlertAction *ok = [UIAlertAction actionWithTitle:@"肯定" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {字符串

        NSDateFormatter* dateFormat = [[NSDateFormatter alloc] init];string

        //实例化一个NSDateFormatter对象it

        [dateFormat setDateFormat:@"yyyy-MM-dd"];//设定时间格式io

        NSString *dateString = [dateFormat stringFromDate:datePicker.date];date

        //求出当天的时间字符串im

        NSLog(@"%@",dateString);margin

    }];

 UIAlertAction *cancel = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {

  }];

[alert addAction:ok];

[alert addAction:cancel];

[self presentViewController:alert animated:YES completion:^{ }];

相关文章
相关标签/搜索