LoginSignup
3
2

More than 5 years have passed since last update.

Swift4でデバイス判断(iPadなの?iPhoneなの?どっちがタイプよ?

Last updated at Posted at 2018-02-15

UIDeviceクラスのUIUserInterfaceIdiomを使って判別します。
・UIDevice
https://developer.apple.com/documentation/uikit/uidevice#//apple_ref/c/tdef/UIUserInterfaceIdiom
・UIUserInterfaceIdiom
https://developer.apple.com/documentation/uikit/uiuserinterfaceidiom

if UIDevice.current.userInterfaceIdiom == .phone {
    print("iPhone")
} else if UIDevice.current.userInterfaceIdiom == .pad {
    print("iPad")
} else {
    print("もしかしてAppleTV?CarPlay?")
}
3
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
2