我有一个用Xamarin.Forms
编写的.xaml
页面,仅在iOS平台上,我试图将页面的内容包装在ScrollView
中,以解决显示键盘时调整大小的问题。 / p>
页面看起来像这样:
<base:mypagebase...>
<ContentPage.Resources>
...
</ContentPage.Resources>
<ContentPage.Content>
<RelativeLayout x:Name="ViewContentLayout" VerticalOptions="FillAndExpand">
....
</RelativeLayou>
</ContentPage.Content>
</base:mypagebase>
在mpage.xaml.cs
之后,我正在尝试在InitializeComponent()
的构造函数中将RelativeLayout
包装在ScrollView
类似这样的东西:
if (Device.RuntimePlatform == Device.iOS)
{
var scroll = new ScrollView();
scroll.Orientation = ScrollOrientation.Vertical;
scroll.VerticalOptions = LayoutOptions.FillAndExpand;
scroll.Content = ViewContentLayout;
Content = scroll;
}
它通过但稍后会引发异常:
Object reference not set to an instance of an object
at Xamarin.Forms.RelativeLayout.OnSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x00017] in RelativeLayout.cs:185
答案 0 :(得分:0)
属性的调用顺序很重要,似乎必须先设置内容根:
updated() {
this.images = images;
console.log(this.$refs);
console.log(this.$refs.im);
}