Swift编码总结9

Swift编码总结9,第1张

概述1.Swift限制textField输入位数为10位: func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool { guard let text = textField.text else{

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 <= 10    }

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)            })
总结

以上是内存溢出为你收集整理的Swift编码总结9全部内容,希望文章能够帮你解决Swift编码总结9所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://www.54852.com/web/1024291.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-23
下一篇2022-05-23

发表评论

登录后才能评论

评论列表(0条)

    保存