如何检测iOS设备类型Xamarin



我想先检测平台是什么,我想检测的是它是手机还是平板电脑。我在网上搜索了很多例子来检测屏幕大小,如高度-宽度,但有没有什么可以让什么是设备类型。

if(Device.RuntimePlatform == Device.iOS)
{
//what is the device type 
}
else if(Device.RuntimePlatform == Device.Android)
{
//what is the device type
}

使用此参数来检测设备类型。


if(Device.RuntimePlatform == Device.iOS)
{
//what is the device type
if (Device.Idiom == TargetIdiom.Phone)
{
Console.WriteLine(Device.Idiom);
}
else if(Device.Idiom == TargetIdiom.Tablet)
{
Console.WriteLine(Device.Idiom);
} 
}
else if(Device.RuntimePlatform == Device.Android)
{
//what is the device type
}

相关内容

最新更新