博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
IOS UIAlertController 弹出框中添加视图(例如日期选择器等等)
阅读量:6890 次
发布时间:2019-06-27

本文共 1112 字,大约阅读时间需要 3 分钟。

hot3.png

UIDatePicker *datePicker = [[UIDatePicker alloc] init]; datePicker.datePickerMode = UIDatePickerModeDate;UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"\n\n\n\n\n\n\n\n\n\n\n\n" 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:^{ }];

需要注意的是,这里没有设置地区时间

    [datePicker setLocale:[[NSLocale alloc]initWithLocaleIdentifier:@"zh_Hans_CN"]];

转载于:https://my.oschina.net/u/554046/blog/529301

你可能感兴趣的文章
Windows Forms中通过自定义组件实现统一的数据验证(二)
查看>>
阿里云海外征战记:跻身全球前三,只用了两年半
查看>>
解密回声消除技术之二(应用篇)
查看>>
Go语言的web程序写法
查看>>
IDF2011:基于SaaS模式的"教学云"案例
查看>>
《Linux From Scratch》第三部分:构建LFS系统 第七章:基本系统配置- 7.5. 配置系统时间...
查看>>
云计算你必须思考的8大问题
查看>>
Windows7 Debug Test
查看>>
HTTPS连接的前几毫秒发生了什么
查看>>
从变量到封装:一文带你为机器学习打下坚实的Python基础
查看>>
给大家共享一个基本算法包
查看>>
Riverbed:SDN向广域网扩展为企业带来哪些价值
查看>>
定义中国网络安全市场战略高度,绿盟科技为“互联网+”保驾护航
查看>>
多维防护:虚拟化安全挑战的破解之道
查看>>
改变数据中心架构的SDN
查看>>
FastDFS分布式文件系统
查看>>
D1net阅闻:SSD固态硬盘将成企业主要存储介质
查看>>
Windows 10 Mobile Build 14383带来数项重要更新
查看>>
LoadRunner 参数化详解
查看>>
智能物流未来有机遇 安防助力发光发热
查看>>