简体   繁体   English

使用Mono Touch的Iphone键盘顶部带有完成按钮的工具栏?

[英]Tool bar with done button on top of keyboard for Iphone using Mono Touch?

I need to add done button on tool bar with UIkeyboard(type) Number Pad, to resign the keyboard while click on done button. 我需要在工具栏上使用UIkeyboard(类型)数字键盘添加完成按钮,以在单击“完成”按钮时退出键盘。 I used Input Accessory View but it adds to normal keyboard also ,i need to add this where i have number pad.For example i have a text field it takes only numbers there i need this.Other than places i don't want to show input Accessory view.Or else i need to show tool bar with Done button for Iphone using Mono Touch. 我使用了Input Accessory View,但它也添加到了普通键盘上,我需要在我有数字键盘的地方添加它。例如,我有一个文本字段,它只需要数字就可以了,除了我不想显示的地方输入附件视图。否则我需要使用Mono Touch为Iphone显示带有完成按钮的工具栏。

Thank you. 谢谢。

    public override UIView InputAccessoryView
    {
        get
        {
            if (dismiss == null)
            {

                UIToolbar toolbar = new UIToolbar(new RectangleF(0, 0, 320, 30));

                toolbar.BarStyle = UIBarStyle.BlackTranslucent;
                dismiss = new UIView(new RectangleF(-20, -120, 320, 30));
                dismissBtn = new UIButton(new RectangleF(268, 1, 50, 29));
                dismissBtn.SetBackgroundImage(new UIImage("Images/done_active.png"), UIControlState.Normal);

                dismissBtn.AllEvents += delegate
                {
                    HideKeyBoard();
                };

                toolbar.AddSubview(dismissBtn);
                dismiss.AddSubview(toolbar);
                dismiss.BringSubviewToFront(dismissBtn);
                dismiss.BringSubviewToFront(toolbar);

            }
            return dismiss;
        }
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM