Views - View.Height += 1 does not have the expected behavior
See original GitHub issueBefore I use view.Height = view.Subviews.Count;
, I had it in another way where I did view.Height += 1;
I remove a lot of other views with Dim and Pos to other views, thinking maybe was circular reference or something.
But no, the problem is just that line … view.Height += 1;
If you try this, it gets exponentially slower.
This is beacuse Dim.Combine
. After 3 times,
view.Height == {Dim.Combine(Dim.Combine(Dim.Combine(Dim.Absolute(0)+Dim.Absolute(1))+Dim.Absolute(1))+Dim.Absolute(1))}
Is this the expected behavior for this case ???
Maybe if it’s the same instance, combine should behave differently, because I think that view.Height += x
is something very basic to have such a behavior.
public override void Setup ()
{
var view = new View () { X = 0, Y = 0, Width = 20, Height = 0 };
var field = new TextField () { X = 0, Y = Pos.Bottom (view), Width = 20 };
field.KeyDown += (k) => {
if (k.KeyEvent.Key == Key.Enter) {
var label = new Label (field.Text) { X = 0, Y = view.Subviews.Count, Width = 20 };
field.Text = "";
view.Add (label);
// works
view.Height = view.Subviews.Count;
// don't try this at home
// view.Height += 1;
}
};
Win.Add (view);
Win.Add (field);
}
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (2 by maintainers)
Top Results From Across the Web
Height not updating on selected view · Issue #535
Expected Behavior When animateHeight={false} this problem does not occur. Every view's height is the same as the maximum view of any view,...
Read more >Can't seem to make auto layout work right
So I have a Split View controller for my app. The Master View Controller does not want to layout correctly in different sizes,...
Read more >ios10: viewDidLoad frame width/height not initialized ...
In Xcode 8, a fully constraint, non-misplaced view no longer saves out a frame to minimize diffs and support automatically update frames in...
Read more >How to make a SwiftUI view to fill its container width and ...
We can use a frame modifier to make a view appear to be full width and height, but the result might not be...
Read more >Understanding SwiftUI Layout Behaviors
When the behavior of a SwiftUI view is not the one you want you cannot alter its properties directly, as views themselves are...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@BDisp Sorry I couldn’t help you.
Yes, there are many ways to do this, but I think that
operators
should work as expected.