简体   繁体   English

Xamarin IOS Stackview

[英]Xamarin IOS Stackview

I'am using visual studio with Xamarin IOS and try to build a storyboard following this design : 我正在使用带有Xamarin IOS的​​visual studio,并尝试按照这种设计构建故事板:

在此输入图像描述

It was easy for UWP and Android but now for IOS i don't understand when i try to use stacklayout. 对于UWP和Android来说很容易,但现在对于IOS我不明白我何时尝试使用stacklayout。 I understood that i must put a stackview vertical inside a view (set the stackview on distribution = fill equally and alignement on fill) but when i try then to add 3 views inside the stackview (top, middle, bottom) nothing work ... In fact i try to build a universal Storyboard which will fit every screen. 我明白我必须在视图中放置一个stackview垂直(在分布上设置stackview =填充等于填充)但是当我尝试在stackview中添加3个视图(顶部,中间,底部)时没有任何工作......事实上,我尝试构建一个适合每个屏幕的通用故事板。

So this is my stacklayout vertical : 所以这是我的stacklayout垂直:

在此输入图像描述

And what it looks like when i add 3 views inside : 当我在里面添加3个视图时它看起来像什么:

在此输入图像描述

Edit 1: 编辑1:

I moved the subviews in the view with copy/paste in the XML file, works better than this designer ... It's possible to say to the stacklayout to fill the width and height of his parent ? 我在视图中移动了子视图,在XML文件中使用了复制/粘贴,比这个设计师效果更好......可以对stacklayout说填充其父级的宽度和高度吗?

在此输入图像描述

Can someone explain me how can i achieve such layout ? 谁能解释我怎样才能实现这样的布局? (i will be crazy) (我会疯了)

Thank you everyone ... 谢谢大家 ...

The is expected behaviour as the same happens when you use a stackview in Xcode Interface Builder. 当您在Xcode Interface Builder中使用stackview时,会发生预期的行为。 By default, the stackview is only as large as the child views. 默认情况下,stackview只与子视图一样大。

To have it resize and fill the superview you need to set some constraints relative to the superview. 要让它调整大小并填充superview,您需要设置一些相对于superview的约束。

For example, you need to create constraints from the leading and trailing edges of the stackview to the superview, then edit them so the constant is 0 - also do the same for the top and bottom. 例如,您需要从stackview的前沿和后沿创建约束到superview,然后编辑它们以使常量为0 - 对于顶部和底部也是如此。

After you have edited the constraints, you need to update the frames to reflect the changes. 编辑约束后,需要更新帧以反映更改。 Do this with the constraint toolbar . 使用约束工具栏执行此操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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