【问题标题】:Add minus button in xamarin ios numeric keypad在 xamarin ios 数字键盘中添加减号按钮
【发布时间】:2021-09-04 20:48:18
【问题描述】:

我需要允许用户在我的 xamarin 应用程序输入字段中输入负值,以来自 IOS 项目。目前我使用以下自定义渲染器来使用 NumbersAndPunctuation 键盘。但我不想要一个仅输入数字输入的字母数字键盘。有没有更好的解决方案?

public class NumericKeypadRenderer: EntryRenderer
  {
        protected override void OnElementChanged(ElementChangedEventArgs<Entry> e)
        {
            base.OnElementChanged(e);

            if (Control == null) return;

        
          Control.KeyboardType = UIKeyboardType.NumbersAndPunctuation;
            
        }
    }

有没有办法在 IOS 的数字小键盘上添加一个减号按钮?

【问题讨论】:

  • 要么创建自己的键盘来显示,要么使用平台为您提供的内容。平台为您提供的内容是不可定制的,您可以添加自定义按钮和操作,除了更改“输入”按钮的行为。

标签: ios xamarin renderer keypad


【解决方案1】:

我们不能只在默认键盘上添加自定义按钮。我们需要自定义键盘来实现这一点。

你可以按照这个帖子来创建你的键盘:Custom Keyboard in Xamarin forms

这个链接有一个sample,你可以参考他的customrenderer:https://github.com/Eren-Shen/CustomKeyboardDemo/tree/master/CustomKeyboardDemo/CustomKeyboardDemo.iOS

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-03-21
    • 1970-01-01
    • 1970-01-01
    • 2013-12-10
    • 2022-11-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-25
    相关资源
    最近更新 更多