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

痞子三分冷 提交于 2019-12-10 11:32:20

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/4175212/how-to-add-a-uitoolbar-on-top-of-uikeyboard-using-monotouch

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!