Dav*_*ser 2 ios swift today-extension
有没有办法确定运行iOS TodayExtension的设备的设备类型.我无法在Swift中执行此操作.
我需要这样的东西:
-(BOOL)isiPad {
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
return YES;
} else {
return NO;
}
}
Run Code Online (Sandbox Code Playgroud)
但是在Swift和TodayExtension中.
编辑:
let IS_IPAD = (UI_USER_INTERFACE_IDIOM()==UIUserInterfaceIdiomPad);
Run Code Online (Sandbox Code Playgroud)
在iOS TodayExtensions中无效.

小智 7
在Swift中,您可以使用此代码.
let isiPad: Bool = (UIDevice.currentDevice().userInterfaceIdiom == .Pad);
Run Code Online (Sandbox Code Playgroud)
在我看来,使用它作为常量.
if (isiPad) {
println(isiPad)
}
else {
println(isiPad)
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2532 次 |
| 最近记录: |