简体   繁体   中英

Xamarin.iOS dynamically ScrollView

I really need your help. I'm new at developing Xamarin.iOS apps and now I'm totally stuck. I cannot get the hang of how to implement a dynamic ScrollView in iOS, it was fairly easy to implement on Android.

So what I'm trying to implement is a view that contains mostly text (that will be quite long, hence the scrolling, but also two buttons.

Here is a gif in Android showing what I'm trying to achieve

The view is like this:

Header Long text Copyright button -- Copyright text Terms of usage button -- Terms of usage text

I have struggled with the scrolling so long and I really need your help. All of the text properties are getting bound to the view by binding with MvvmCross so the view can't be with hard-coded heights and widths, it needs to adjust properly.

Can somebody please show me with a sample project how to implement it?

The view needs to be in a .xib view (because of MvvmCross) and it cannot contain a UIViewcontroller.

So the solution needs to be in a simple UIView

I'm working on a Windows, with Visual Studio 2015 enterprise, and I cannot use a Mac (and Xcode) other than to compile my code with.

What I've tried is a solution like this:

UIView called "MyRootview"
-- UIScrollView called "MyScrollView"
-- -- UIView called "MyContentView"

Can you please help me?

Method 1:

Use a TableView instead of ScrollView. Make the header row 1, long text row 2, button 1 and it's text row 3 and button 4 and it's text row 4.

Give row height for the last 2 rows so that you only see the button and on button click increase the row height and reload the table section.

Method 2:

If you keep wanna using ScrollView, put the button data in a label and give it a height of 0 (and number of lines 1) to hide it and on button click remove the height constraint and set the number of lines to 0 (max).

I used FluentLayout instead. Very easy.

https://github.com/FluentLayout/Cirrious.FluentLayout

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM