Skip to content

YGOverflowScroll is not working with UIScrollView #940

@peanut196

Description

@peanut196

[self.view configureLayoutWithBlock:^(YGLayout * _Nonnull layout) {
layout.isEnabled = YES;
layout.flexDirection = YGFlexDirectionColumn;
}];
UIScrollView *scrollview = [[UIScrollView alloc] init];
[self.view addSubview:scrollview];
[scrollview configureLayoutWithBlock:^(YGLayout * _Nonnull layout) {
layout.isEnabled = YES;
layout.width = YGPercentValue(100);
layout.height = YGPercentValue(100);
layout.flexDirection = YGFlexDirectionColumn;
layout.overflow = YGOverflowScroll;
}];
UIView *view1 = [[UIView alloc] init];
[view1 setBackgroundColor:[UIColor redColor]];
[scrollview addSubview:view1];
[view1 configureLayoutWithBlock:^(YGLayout * _Nonnull layout) {
layout.isEnabled = YES;
layout.width = YGPercentValue(100);
layout.height = YGPercentValue(50);
}];

UIView *view2 = [[UIView alloc] init];
[view2 setBackgroundColor:[UIColor yellowColor]];
[scrollview addSubview:view2];
[view2 configureLayoutWithBlock:^(YGLayout * _Nonnull layout) {
    layout.isEnabled = YES;
    layout.width = YGPercentValue(100);
    layout.height = YGPercentValue(50);
}];


UIView *view3 = [[UIView alloc] init];
[view3 setBackgroundColor:[UIColor purpleColor]];
[scrollview addSubview:view3];
[view3 configureLayoutWithBlock:^(YGLayout * _Nonnull layout) {
    layout.isEnabled = YES;
    layout.width = YGPercentValue(100);
    layout.height = YGPercentValue(50);
}];


UIView *view4 = [[UIView alloc] init];
[view4 setBackgroundColor:[UIColor cyanColor]];
[scrollview addSubview:view4];
[view4 configureLayoutWithBlock:^(YGLayout * _Nonnull layout) {
    layout.isEnabled = YES;
    layout.width = YGPercentValue(100);
    layout.height = YGPercentValue(50);
}];

[self.view.yoga applyLayoutPreservingOrigin:NO];

After call ApplyLayout, scrollview contentSize not correct

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions