у меня есть таблица с textField в ячейке y под этой таблицей, у меня есть textField
-------------------------------------------
- --------------------------------------- -
- - text field in table - -
- ------------------------------------- - -
-------------------------------------------
- --------------------------------------- -
- - other textField - -
- ------------------------------------- - -
, затем я сделал библиотеку для входа с клавиатуры
public static void KeyBoardUpNotification(NSNotification notification)
{
scrollamount = 0.0f;
RectangleF rectangle = (RectangleF)UIKeyboard.BoundsFromNotification(notification);
if (currentView == null)
{
return;
}
if (activeview==null) {
foreach (UIView view in currentView.Subviews)
{
if (view.IsFirstResponder)
{
activeview = view;
activeview.BecomeFirstResponder();
}
}
}
if (activeview == null)
{
return;
}
bottom = ((float)(activeview.Frame.Y + activeview.Frame.Height + offset));
scrollamount = ((float)(rectangle.Height - (currentView.Frame.Size.Height - bottom)));
if (scrollamount != 0)
{
moveViewUp = true;
ScrollTheView(moveViewUp);
}
else
{
moveViewUp = false;
}
}
public static void KeyBoardDownNotification(NSNotification notification)
{
if (moveViewUp) ScrollTheView(false);
}
private static void ScrollTheView(bool move)
{
UIView.BeginAnimations(string.Empty, IntPtr.Zero);
UIView.SetAnimationDuration(0.3);
RectangleF frame = (RectangleF)currentView.Frame;
if (move)
{
frame.Y = y;
frame.Y -= scrollamount;
}
else
{
frame.Y = y;
scrollamount = 0;
moveViewUp = false;
}
currentView.Frame = frame;
UIView.CommitAnimations();
scrollamount = 0;
frame.Y = 0;
}
, но когда фокус находится в текстовом поле из ячейки, этот код не работает, камера фокусируется на текстовом поле ниже.
, но этот код работает только в текстовом поле ниже, камера фокусируется на текстовом поле ниже, и это хорошо.