我想首先檢測什么是平臺,我想檢測的是它是手機還是平板電腦。我在互聯網上搜索了很多示例來檢測螢屏尺寸(如高度-寬度),但是有什么可以讓設備型別是什么的。
if(Device.RuntimePlatform == Device.iOS)
{
//what is the device type
}
else if(Device.RuntimePlatform == Device.Android)
{
//what is the device type
}
uj5u.com熱心網友回復:
使用它來檢測設備型別。
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
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/497395.html
標籤:xamarin xamarin.android xamarin.ios
下一篇:類成員分配中的委托與lambda