【问题标题】:How to add a UIToolbar on top of UIKeyboard using MonoTouch?如何使用 MonoTouch 在 UIKeyboard 上添加 UIToolbar?
【发布时间】:2010-11-13 23:11:18
【问题描述】:

我按照 Custom iPhone Keyboard 的 Obj-C 中的示例在 Windows 子视图中查找 UIKeyboard,但是,我不知道如何使用 MonoTouch 来执行此操作。我不知道“描述”是什么。如果它是 UIView 的属性,我无法从 MonoTouch 访问它???

谁能提供一个在 Obj-C 示例中但在 C# 中查找 UIKeyboard 以在 MonoTouch 中使用的示例?

谢谢。

【问题讨论】:

    标签: iphone objective-c xamarin.ios uitoolbar uikeyboard


    【解决方案1】:

    我假设您正在寻找与 Safari 中的键盘相同的东西(即,它在顶部有一个小工具栏,可以添加额外的功能,如最右边的图片 here 所示)

    在这种情况下,您正在寻找的是输入附件视图(iOS 3.2 及更高版本)。在 Monotouch 中,这样做的方法是在视图控制器中覆盖 Input Accessory View。一个我之前用过的简单例子

    public override UIView InputAccessoryView 
    {
        get 
        {
            UIView dismiss = new UIView(new RectangleF(0,0,320,27));
            dismiss.BackgroundColor = UIColor.FromPatternImage(new UIImage("Images/accessoryBG.png"));          
            UIButton dismissBtn = new UIButton(new RectangleF(255, 2, 58, 23));
            dismissBtn.SetBackgroundImage(new UIImage("Images/dismissKeyboard.png"), UIControlState.Normal);        
            dismissBtn.TouchDown += delegate {
                 subjectField.ResignFirstResponder();
            };
            dismiss.AddSubview(dismissBtn);
            return dismiss;
        }
    }
    

    这只是在键盘顶部创建一个 UIView,然后您可以像往常一样将您想要的任何内容添加到视图中。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-10-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多