コード例 #1
0
    void ShowCallback(object sender, MonoTouch.UIKit.UIKeyboardEventArgs args)
    {
        // This happens if the user focuses a textfield outside of the
        // tableview when the tableview is empty.
        UIView activeView = this.View.FindFirstResponder();

        if ((activeView == null) || (activeView == Customer))
        {
            return;
        }
        // Get the size of the keyboard
        RectangleF keyboardBounds = args.FrameEnd;
        // Create an inset and assign it to the tableview
        UIEdgeInsets contentInsets = new UIEdgeInsets(0.0f, 0.0f, keyboardBounds.Size.Height, 0.0f);

        myTableView.ContentInset          = contentInsets;
        myTableView.ScrollIndicatorInsets = contentInsets;
        // Make sure the tapped location is visible.
        myTableView.ScrollRectToVisible(activeView.Frame, true);
    }
コード例 #2
0
 void HideCallback(object sender, MonoTouch.UIKit.UIKeyboardEventArgs args)
 {
     // If the tableView's ContentInset is "zero", we don't need to
     // readjust the size
     if (myTableView.ContentInset.Top == UIEdgeInsets.Zero.Top)
     {
         return;
     }
     // Remove the inset when the keyboard is hidden so that the
     // TableView will use the whole screen again.
     UIView.BeginAnimations(""); {
         UIView.SetAnimationCurve(args.AnimationCurve);
         UIView.SetAnimationDuration(args.AnimationDuration);
         var viewFrame   = View.Frame;
         var endRelative = View.ConvertRectFromView(args.FrameEnd, null);
         viewFrame.Height                  = endRelative.Y;
         View.Frame                        = viewFrame;
         myTableView.ContentInset          = UIEdgeInsets.Zero;
         myTableView.ScrollIndicatorInsets = UIEdgeInsets.Zero;
     } UIView.CommitAnimations();
 }