gpt4 book ai didi

xamarin.ios - Monotouch - 使 UIView 可滚动

转载 作者:行者123 更新时间:2023-12-04 03:02:18 26 4
gpt4 key购买 nike

我有一个带有 4 个文本框和顶部的 Logo 的 View - 当用户输入信息时,文本板会覆盖其中的一些控件,我怎样才能使 View 滚动以便这不是问题。

我尝试将 View 添加到 UIScrollView但这似乎没有任何作用?

最佳答案

我在下面包含了我如何处理您的情况的片段。如果我对您的理解正确,您不希望有一个可滚动的 View ,而是希望 View 与在字段之间的切换一起移动,以减轻键盘造成的视觉障碍。

祝你好运!

private void ScrollTheView(bool movedUp, float scrollamount, UIView ViewToMove)
{
//To invoke a views built-in animation behaviour,
//you create an animation block and
//set the duration of the move...
//Set the display scroll animation and duration...
UIView.BeginAnimations(string.Empty, System.IntPtr.Zero);
UIView.SetAnimationDuration(0.15);

//Get Display size...
RectangleF frame = ViewToMove.Frame;

if (movedUp) {
//If the view should be moved up,
//subtract the keyboard height from the display...
frame.Y -= scrollamount;
}
else {
//If the view shouldn't be moved up, restore it
//by adding the keyboard height back to the original...
frame.Y += scrollamount;
}

//Assign the new frame to the view...
ViewToMove.Frame = frame;

//Tell the view that your all done with setting
//the animation parameters, and it should
//start the animation...
UIView.CommitAnimations();

}

关于xamarin.ios - Monotouch - 使 UIView 可滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2348259/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com