开发者

How to add a UIToolbar on top of UIKeyboard using MonoTouch?

I follow the example in Obj-C开发者_如何学JAVA 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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜