【问题标题】:Xamarin.Forms Datepicker NullReferenceException ios 9.0Xamarin.Forms Datepicker NullReferenceException ios 9.0
【发布时间】:2019-10-23 14:48:07
【问题描述】:

我在视图中添加了 Datepicker 控件。在高于 10.0 的 iOS 版本上一切正常。

但在 iOS 9.0 上,Datepicker 会抛出 NullReferenceException。

有谁知道如何防止这个异常?

【问题讨论】:

  • 这种情况什么时候发生?异常详情是什么?
  • @FreakyAli 为问题添加了详细信息
  • 在自定义渲染器中发布代码并共享项目。也许你调用了一些在 iOS 10.0 之后可用的 API。
  • 可以分享picker选择更改事件中的代码吗?同时分享 Xaml

标签: xamarin xamarin.forms datepicker xamarin.ios


【解决方案1】:

它已经是 Xamarin Forms GitHub 中的一个已知错误。 link。所以 XF 渲染器中的问题。

作为解决方案,我为 Pickers 实现了自己的 Renderer 并添加了 null 检查

if (entry.InputAssistantItem != null)
{
    entry.InputAssistantItem.LeadingBarButtonGroups = null;
    entry.InputAssistantItem.TrailingBarButtonGroups = null;
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-05-08
    • 2017-04-12
    • 2015-03-13
    • 2017-06-05
    • 2015-10-23
    • 2016-09-24
    • 1970-01-01
    相关资源
    最近更新 更多