如何使用 MonoTouch 在 UIKeyboard 之上添加 UIToolbar?

发布于 2024-10-02 20:45:30 字数 323 浏览 7 评论 0原文

我按照 Obj-C 中 自定义 iPhone 键盘 中的示例来查找 UIKeyboard然而,Windows SubViews,我不知道如何使用 MonoTouch 来做到这一点。我不知道“描述”是什么。如果它是 UIView 的属性,我无法从 MonoTouch 访问它???

有人可以提供一个在 Obj-C 示例中查找 UIKeyboard 的示例,但在 C# 中用于 MonoTouch 吗?

谢谢。

I follow the example in Obj-C at Custom iPhone Keyboard for finding the UIKeyboard in the Windows SubViews, however, I don't know how to do this using MonoTouch. I don't know what the "description" is. If it is a property of UIView I cannot access it from MonoTouch???

Can someone please provide an example of finding the UIKeyboard as in the Obj-C sample but in C# for use in MonoTouch?

Thank you.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

奶茶白久 2024-10-09 20:45:30

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

在这种情况下,您要查找的是输入附件视图(iOS 3.2 及更高版本)。在 Monotouch 中,执行此操作的方法是覆盖视图控制器中的输入附件视图。我之前使用过的一个简单示例

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,然后您可以像平常一样将任何您想要的内容添加到视图中。

I assume you're looking for the same thing as the keyboard in Safari (i.e. it has a small toolbar at the top that adds extra functionality, as seen on the far right image here )

In that case, what you're looking for is the Input Accessory View (iOS 3.2 and above). In Monotouch, the way to do this is to override Input Accessory View in your view controller. A simple example I've used before

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;
    }
}

This just creates a UIView across the top of the keyboard, you can then add whatever you'd like to the view as normal.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文