Xcode:9.2
Swift:4.0.3
使用中のデバイスを判定するには、UIDevice.current.userInterfaceIdiomを使用します。
例えば、現在使用中のデバイスがiPadかを調べるには、以下のコードで調べることができます。
if UIDevice.current.userInterfaceIdiom == .pad {
}
userInterfaceIdiomには以下のような値があります。
| 値 | 説明 |
|---|---|
| phone | iPhone |
| pad | iPad |
| tv | Apple TV |
| carPlay | Car Play |