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
if UIDevice.current.userInterfaceIdiom == .pad {
print("iPad")
}else{
print("not iPad")
}
But you need to make your app a universal app.