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) })
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。