Hi,
My UI has it's own navigation bar image (the actual Navbar is hidden) with usually a pile of text boxes on the screen. To get around this, I've included the following in my source to scroll the textview/textfield to above the keyboard
txtCountry.EditingDidBegin += delegate
{
AnimateTextField(View, true);
SetKeyboardEditorWithCloseButton(txtCountry, UIKeyboardType.Default);
};
public static void AnimateTextField(UIView view, bool direction)
{
int moveDist = 80;
double moveDur = 0.3;
int move = (direction ? -moveDist : 0);
UIView.BeginAnimations("anim");
UIView.SetAnimationBeginsFromCurrentState(true);
UIView.SetAnimationDuration(moveDur);
view.Frame = new RectangleF(view.Frame.X, (float)move, view.Bounds.Width, view.Bounds.Height);
UIView.CommitAnimations();
}
public static void SetKeyboardEditorWithCloseButton(UITextField txt, UIKeyboardType keyboardType)
{
var toolbar = new UIToolbar
{
BarStyle = UIBarStyle.Black,
Translucent = true,
};
txt.KeyboardType = keyboardType;
toolbar.SizeToFit();
var doneButton = new UIBarButtonItem(StringUtils.GetString("Common.Done"), UIBarButtonItemStyle.Done,
(s, e) =>
{
txt.ResignFirstResponder();
});
toolbar.SetItems(new UIBarButtonItem[]{ doneButton }, true);
txt.InputAccessoryView = toolbar;
}
This code works fine and dandy but with one issue. The banner at the top is also moved off the screen. Is there any way that I can make the View scroll up but leave the bar where it is?
Thanks