zoukankan      html  css  js  c++  java
  • iOS8 UIAlertController弹出框中添加视图(例如日期选择器等等)

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

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

    [alert.view addSubview:datePicker];

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

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

            //实例化一个NSDateFormatter对象

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

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

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

            NSLog(@"%@",dateString);

        }];

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

      }];

    [alert addAction:ok];

    [alert addAction:cancel];

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

  • 相关阅读:
    equals方法
    StringBudilde
    日期
    system
    File类
    calender
    stringbuilder tostring
    File的三种构造方法
    Java入门——day52
    Java入门——day53
  • 原文地址:https://www.cnblogs.com/weiboyuan/p/4062469.html
Copyright © 2011-2022 走看看