To detect current device with iOS/Swift we can use UserInterfaceIdiom. It is an enum in swift, which tells which device is being used. The interface idiom provides multiple values in it's enum which are. When we run the above code on an iPhone device following is the result produced.
To determine if a device is iPhone or iPad with React Native, we can use the Platform. isPad property. If it's true , then it's an iPad. If it's false , it's an iPhone.
Apple Inc. In 2010 Apple unveiled the iPad, a touch-screen device intermediate in size between a laptop computer and a smartphone with a display that measured 9.7 inches (24.6 cm) diagonally. It was about 0.5 inch (1.2 cm) thin and weighed 1.5 pounds (0.7 kg).
Tap Settings > [your name], then scroll down. Tap any device name to view that device's information, such as the device model, serial number, OS version, and whether the device is trusted and can be used to receive Apple ID verification codes.
You can use
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
In Swift you can use:
if UIDevice.current.userInterfaceIdiom == .pad {
//do stuff
}
you must cheack the condition wheather device is iphone/ipad
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
//do ur ipad logic
}else
{
//do ur iphone logic
}
If you are using swift, use this
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiom.Pad)
{
// device is ipad
}
else
{
// device is iPhone
}
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