Avatar ·

Determining iPad device in iOS app using Swift

Hello everyone! I'm new to iOS development and I've encountered a task: I need to determine if the app is running on an iPad to adapt the interface. For example, on iPad I want to show a split view, and on iPhone — regular navigation.\n\nI tried using UIDevice.current.userInterfaceIdiom, but I'm not sure if this is a reliable way. Here's my code:\n\n```swift\nif UIDevice.current.userInterfaceIdiom == .pad {\n print("This is iPad")\n} else {\n print("This is iPhone or iPod")\n}\n```\n\nBut I've read that on iPad in Split View or Slide Over mode, this property can behave ambiguously. I've also seen that some people use UIScreen.main.traitCollection.userInterfaceIdiom, but I don't understand the difference.\n\nPlease advise how to correctly and reliably determine if the app is running on an iPad? Maybe there's