我必须为验光师编写一个查看测试。所以他们需要数字准确地具有特定的高度。他有一个 iPad 并将其流式传输到电视上。我知道我必须考虑电视的 PPI。这是我的代码:
func calcPoints() -> Float {
// he gives the Visus with a TextField
let visus = Float(textFieldVisus.text!)
// Here you put in the PPI of the device
let ppi = Float(textFieldDPI.text!)
// Calculate the lenght of the Number
let lenght = ((0.29 * 5) / visus!) * 5
// Calculate the Points (because TextFiels work with Points)
let points = ((ppi! / 25.4) * lenght) * 0.75
// here you divide with 2 because you have a retina Display on the IPad
return (points / 2)
}
func passeUIan() {
// Now i can give the Points to the TextField
textField1.bounds.size.width = CGFloat(calcPoints())
textField1.bounds.size.height = CGFloat(calcPoints())
textField1.font = UIFont(name: (textField1.font?.fontName)!, size: CGFloat(calcPoints()))
}
但是当我在电视上测量长度时,它是错误的。通常它必须是 7.25 毫米,但大约是 9 毫米。我不知道出了什么问题。我从2周开始搜索这个问题......