有时候我们做游戏,会针对ipad或者iphone做一些特殊的设置,让其游戏更好的适应不同的设备,这样,我们就需要在代码里分辨和判断打开游戏的是什么设备,好调用相应的逻辑处理。好吧,这个没什么大问题,直接贴代码吧
//分辨不同设备
if UIDevice.currentDevice().userInterfaceIdiom == UIUserInterfaceIdiom.Phone{
print("iphone")
}
if UIDevice.currentDevice().userInterfaceIdiom == UIUserInterfaceIdiom.Pad{
print("ipad")