我想检查iPhone或iPad是否使用这些代码
if traitCollection.userInterfaceIdiom == UIUserInterfaceIdiom.Phone {
println("iPhone")
} else {
println("iPad")
}
Run Code Online (Sandbox Code Playgroud)
我尝试使用iPhone模拟器和我的iPhone,但它打印了"iPad"
然后我试着打印"traitCollection.userInterfaceIdiom"
println(traitCollection.userInterfaceIdiom.rawValue)
Run Code Online (Sandbox Code Playgroud)
它打印"-1"而不是"0"(iPhone)或"1"(iPad)
我不知道问题出在哪里,我一直在搜索谷歌,但还没有发现这里发生了什么.