问题描述
如果稍微倾斜ios设备,sfcomboBox在xamarin.forms中向上滚动到顶部。这是我们第一次进入页面时发生的。
<comboBox:SfComboBox DataSource="{Binding SamplePickerList,Mode=TwoWay}" HorizontalOptions="FillAndExpand" Selectedindex="{Binding SamplePickerIndex,Mode=TwoWay}"
VerticalOptions="FillAndExpand" SelectedItem="{Binding SamplePicker,Mode=TwoWay}" />
解决方法
您可以通过使用 SfComboBox Renderer 并获取设备旋转和 UITableView 内容偏移位置来解决此问题。您可以通过查看其 ContentOffset 属性轻松获取 table view 的确切偏移量。
代码片段:
public class CustomComboBoxRenderer : SfComboBoxRenderer
{
/// <summary>
/// Find device rotation.
/// </summary>
UIDeviceOrientation orientation;
public CustomComboBoxRenderer()
{
Foundation.NSNotificationCenter.DefaultCenter.AddObserver(new NSString("UIDeviceOrientationDidChangeNotification"),this.DeviceRotated);
}
private async void DeviceRotated(NSNotification obj)
{
if (this.Control.Text == string.Empty && this.Control.IsSuggestionOpen)
{
//// Get the table view position.
var offset = this.Control.AutoCompleteTableView.TableView.ContentOffset;
await System.Threading.Tasks.Task.Delay(1);
//// Set the table view position while rotating.
this.Control.AutoCompleteTableView.TableView.ContentOffset = offset;
}
}
}
在此示例中,我们使用 UIDeviceOrientation 保存旋转前的滚动位置,然后在设备倾斜后滚动到该行。
,我们已根据您提供的信息分析了您的查询并检查了报告的问题,但我们无法重现该问题。我们试图重现问题的示例可以从下面下载。
示例: https://www.syncfusion.com/downloads/support/directtrac/general/ze/ComboBoxSample1920214537.zip
由于我们不知道问题的确切情况,请您检查所附样本的问题,并告诉我们它是否被复制?如果此示例中未重现该问题,请根据您的应用程序修改示例以及复制程序或提供示例来回复我们。这将有助于我们进一步调查并尽早为您提供更好的解决方案。
问候, Sakthivel P.