[英]Error — Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc failed with exit code 1
I am working on a custom keyboard and if i include this code in my class the i got the error: 我正在使用自定义键盘,如果我在我的课程中包含此代码,我收到错误:
let isPad = UIDevice.currentDevice().userInterfaceIdiom == UIUserInterfaceIdiom.Pad
Error - Command/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc failed with exit code 1
I need this code because when user runs iPhone app (like instagram) on iPad, I need to load iPhone keyboard preset and use its geometry. 我需要这个代码,因为当用户在iPad上运行iPhone应用程序(如Instagram)时,我需要加载iPhone键盘预设并使用其几何体。 I have try below code but it is not a solution:
我尝试下面的代码,但它不是一个解决方案:
if UI_USER_INTERFACE_IDIOM() == .Pad { 如果UI_USER_INTERFACE_IDIOM()== .Pad {
} }
So please share if anyone have any solution. 如果有人有任何解决方案,请分享。
Try this: 试试这个:
if UIDevice.currentDevice().userInterfaceIdiom == .Pad {
// iPad Stuff
}
else if UIDevice.currentDevice().userInterfaceIdiom == .Phone {
// iPhone Stuff
}
EDIT 编辑
Swift 3 斯威夫特3
if UIDevice.current.userInterfaceIdiom == .pad {
// iPad Stuff
}
else if UIDevice.current.userInterfaceIdiom == .phone {
// iPhone Stuff
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.