Swift编码总结9
2024-09-03 01:19:44
1.Swift限制textField输入位数为10位:
func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {
guard let text = textField.text else{
return true
}
let textLength = text.count + string.count - range.length
return textLength <=
}
2.iOS float与double的范围和精度:
https://www.jianshu.com/p/ab37c083317b
// 这里账单金额过大的时候会造成小数点被抹了 po bill["billMoney"]! 5978501.1
// let formatMoney = String(format: "%.2f", (bill["billMoney"] as? Double)!)
// footPriceLabel.text = String.getSeparatedString(orgStr: String.stringValue(formatMoney, defaultValue: "0"))
3.whose view is not in the window hierarchy:
该错误简单的说,是由于 "ViewController" 还没有被加载,就调用该 ViewController 或者 ViewController 内的方法时,就会报这个错误。
self.dismiss(animated: false, completion: {
let vc = PersonAAController()
vc.personNum = num
// print((UIApplication.shared.delegate as? AppDelegate)?.window?.rootViewController.self)
// whose view is not in the window hierarchy
var rootVC = (UIApplication.shared.delegate as? AppDelegate)?.window?.rootViewController
while ((rootVC?.presentedViewController) != nil) {
rootVC = rootVC?.presentedViewController
}
rootVC?.popup(controller: vc, direction: .center)
})
最新文章
- iOS开发之SQLite--C语言接口规范(三)——Binding Values To Prepared Statements
- 帆软报表FineReport中数据连接的JDBC连接池属性问题
- javascript优化--11模式(设计模式)02
- ci配置smarty手记
- Android studio 环境搭建
- Makefile中=、:=、+=、?=的区别
- 开通GitHub以及使用笔记
- sqlserver中的锁
- C#学习笔记(4)
- 探求Floyd算法的动态规划本质(转)
- Laravel Migrate
- 地理位置 API
- Windows Internals 笔记——进程的权限
- ";hello,world";———C++入门有感
- java329 继承、类的高级概念
- T 分布(近似标准正态分布)
- IOS UIView圆角,阴影,边框,渐增光泽
- 汽车检测SIFT+BOW+SVM
- Windows ";计划任务";功能设置闹钟~
- SET HANDLER - FOR
热门文章
- 品优购项目 单表过程 乒乓过程 入口 MyBatis逆向工程 dubbo框架搭建 品牌表CRUD bug集锦
- ECMAScript规范解读this
- Game of Cards Gym - 101128G (SG函数)
- LeetCode 737. Sentence Similarity II
- 使用nodegui 开发高性能的跨平台桌面端应用
- 8-ESP8266 SDK开发基础入门篇--编写串口上位机软件
- swoolefy PHP的异步、并行、高性能网络通信引擎内置了Http/WebSocket服务器端/客户端
- GitHub上如何创建文件夹
- trutle库的使用基础
- SSL证书创建与部署