我是Xamarin的新手。Forms目前正在接受在线课程。我正在使用Visual Studio for Mac。
我有一个简单的表格:
<?xml version="1.0" encoding="UTF-8"?>
<ContentPage
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="HelloWorld.GreetPage">
<StackLayout HorizontalOptions="Center" VerticalOptions="Center" Orientation="Vertical" Padding="0">
<Label Text="Hello World" />
<Slider />
</StackLayout>
</ContentPage>
和更简单的代码隐藏:
using System;
using System.Collections.Generic;
using Xamarin.Forms;
namespace HelloWorld
{
public partial class GreetPage : ContentPage
{
public GreetPage()
{
InitializeComponent();
}
}
}
当我在Android设备上编译并运行它时,正如我期望的那样,我在滑块上方看到“ Hello World”标签。但是,在我的iPhone上,我只看到滑块,没有标签。还有其他人遇到吗?谢谢。
我还尝试用C#代替XAML手动创建StackLayout
:
using System;
using System.Collections.Generic;
using Xamarin.Forms;
namespace HelloWorld {
public partial class GreetPage : ContentPage
{
public GreetPage()
{
InitializeComponent();
Content = new StackLayout
{
HorizontalOptions = LayoutOptions.Center,
VerticalOptions = LayoutOptions.Center,
Children =
{
new Label { Text = "Hello World" },
new Slider { }
}
};
}
}
}
而我 still 只得到滑块。
有趣的是,在模拟器上运行应用程序时不存在此问题。 Android可以正常工作。
请帮助!