I am currently updating an app and I need to know whether the app is being used in an iPad or not.
I checked online and I found the code below. I used the iPad simulators in Xcode and ran both if statements. but whenever I run the code, nothing happens (the print message does not print) does this code work with simulators or am I doing something wrong?
When I check if it is UIUserInterfaceIdiom.phone the print statement executes, but I am using an iPad in the simulator.
if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiom.pad){
print("This is an iPad")
redoButton.layer.position.y -= 500
}
if UIDevice.current.userInterfaceIdiom == .pad{
print("iPad True")
}
Thank You
Go to mysupport.apple.com. Sign in with your Apple ID. Choose your device. You can see details about the support that you're eligible for—including hardware repairs and technical support.
If want your iPhone and iPad to work smoothly together, you have to go through a couple of steps. Log in with the same Apple ID on both devices, connect the devices to the same WiFi network, turn on Bluetooth and Handoff. Handoff is easy to turn on. You go to 'Settings' and tap 'General' > 'Airplay and Handoff'.
Make sure that iOS software is up to date. On your iOS device, go to Settings then Bluetooth and make sure that Bluetooth is on. If you can't turn on Bluetooth or you see a spinning gear, restart your iOS device. Unpair the Bluetooth accessory and put it back in discovery mode, then try to pair it again.
if UIDevice.current.userInterfaceIdiom == .pad {
print("iPad")
}else{
print("not iPad")
}
But you need to make your app a universal app.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With