首页 > 编程语言 > 详细

Swift编码总结9

时间:2018-06-26 20:39:54      阅读:192      评论:0      收藏:0      [点我收藏+]

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

原文:https://www.cnblogs.com/pengsi/p/9230982.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!