Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/106.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios Swift 2.0中的CGFloat_Ios_Xcode_Swift_Swift2_Cgfloat - Fatal编程技术网

Ios Swift 2.0中的CGFloat

Ios Swift 2.0中的CGFloat,ios,xcode,swift,swift2,cgfloat,Ios,Xcode,Swift,Swift2,Cgfloat,在将Swift更新到2.0之后,我需要修复我的代码。自动更正不起作用 func getValueForKey(key: String) -> CGFloat { var inch = "" if screenSize.height == 480 { // iPhone 4, 4s and below inch = "3.5" } else if screenSize.height == 568

在将Swift更新到2.0之后,我需要修复我的代码。自动更正不起作用

func getValueForKey(key: String) -> CGFloat {
        var inch = ""
        if screenSize.height == 480 {
            // iPhone 4, 4s and below
            inch = "3.5"
        } else if screenSize.height == 568 {
            // iPhone 5, 5s
            inch = "4"
        } else if screenSize.width == 375 {
            // iPhone 6
            inch = "4.7"
        } else if screenSize.width == 414 {
            // iPhone 6+
            inch = "5.5"
        } else if screenSize.width == 768 {
            // iPad
            inch = "5.5+"
        }
        let result = values["\(key)\(inch)"]!
        //        println("\(key) - \(result)")
        return result
    }

我改了。 但是什么也没发生,它又出现了


如何修复它?

原因是缺少库UIKit

import UIKit

此课前代码已解决问题。

要详细说明导入
UIKit
解决此问题的原因,请执行以下操作:

CGFloat
结构是
CoreGraphics
框架的一部分
UIKit
默认导入
Foundation
,后者导入
CoreGraphics

如果您没有使用
UIKit
或在没有
UIKit
框架的平台上(如Linux),导入
Foundation
模块将导入
CoreGraphics

,使用以下方法似乎就足够了:
导入CoreGraphics。

hm..它对我有效…它实际上在CoreGraphics中声明,请尝试重新启动xcodeThx)导入UIKit帮助。。。我的失败(但它在…奇怪的事情发生之前起作用):D