LoginSignup
32
28

More than 5 years have passed since last update.

SwiftでiPhoneとiPadを判別する

Last updated at Posted at 2014-12-05

UIDeviceクラスのUIUserInterfaceIdiomを使います。


enum UIUserInterfaceIdiom : Int {
    case Unspecified

    case Phone // iPhone and iPod
    case Pad // iPad
}

このような定義があるので、判別は下記のようにかけます。

if UIDevice.currentDevice().userInterfaceIdiom == .Phone {
    println("iPhone")
}else if UIDevice.currentDevice().userInterfaceIdiom == .Pad{
    println("iPad")
}else{
    println("Unspecified")
}

公式リファレンス:UIDevice
https://developer.apple.com/library/ios/documentation/Uikit/reference/UIDevice_Class/index.html#//apple_ref/c/tdef/UIUserInterfaceIdiom

32
28
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
32
28