Monotouch - make UIView scrollable

I have a view with 4 text fields and a logo at the top - when the user enters information, the text panel closes some of these controls, how can I scroll the view so that this is not a problem.

I tried adding a view to the UIScrollView , but it does nothing?

+4
source share
3 answers

I have included snippet below how I dealt with your situation. If I understand you correctly, you don’t want to have a scrollable view, rather you want the view to move in conjunction with switching to and from the fields to alleviate the visual noise caused by the keyboard.

Good luck!

 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(); } 
+1
source

You need to install more in UIScrollView than just put subviews in it. Correctly set the ContentSize property for the full size of the subqueries so that the scroll will look at information about more content in it than you can control the scroll position, scale factor, etc.

There are many examples in the iOS SDK, just check the UIScrollView documentation, conversion to Monotouch from ObjectiveC is simple, or check the blog entry http://blog.touch4apps.com/home/iphone-monotouch-development/monotouch-infinite-loop-image- scroll-view where I have a sample with images authorized in UIScrollView.

0
source

something like that.

 textBox.EditingDidBegin += delegate { var offset = scrollView.contentOffset; offset.Y -= 200; scrollView.contentOffset = offset; } 
0
source

Source: https://habr.com/ru/post/1302603/


All Articles