Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

YGOverflowScroll is not working with UIScrollView #940

Closed
peanut196 opened this issue Oct 23, 2019 · 2 comments
Closed

YGOverflowScroll is not working with UIScrollView #940

peanut196 opened this issue Oct 23, 2019 · 2 comments
Labels

Comments

@peanut196
Copy link

[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

facebook-github-bot pushed a commit that referenced this issue Apr 27, 2023
Summary:
X-link: facebook/litho#940

Pull Request resolved: #1252

X-link: facebook/react-native#36993

Fabric relies on the private C++ internals of Yoga. This creates a conundrum in the open source build due to how header creation in Cocoapods works.

1. The default mechanism of specifying public headers needs to include the private headers for them to be made usable by fabric (by default)
2. Cocoapods will roll up all of the public headers when importing a module

facebook/react-native#33381 fixed the Fabric Cocoapods build which ran into this. React Native relies on FlipperKit which relies on YogaKit, which in turn finally imports the Yoga podspec. Because YogaKit may use Swift, we can only expose the public Yoga C ABI.

The first solution in that PR was to allow RN to access Yoga private headers, but this was changed to instead make all Yoga headers public, and to add ifdefs to all of them to no-op when included outside of a C++ environment.

Talking to Kudo, we should be able to change back to the earlier approach in the PR, to instead expose the private headers to only RN. This lets us avoid exposing headers that we ideally wouldn't be, and lets us avoid the messy ifdefs in every Yoga header.

Changelog: [Internal]

Reviewed By: rshest

Differential Revision: D45139075

fbshipit-source-id: 99152986a578f7aac8324dffe0e18c42a38cc6a5
@NSKevin
Copy link

NSKevin commented May 15, 2023

Any Update ? I found that YGValueAuto is work out but YGPercentValue(100) does not .

@NickGerleman
Copy link
Contributor

We are deprecating YogaKit as part of the Yoga 2.0 release. We are still going to release a new revision based on the current state of the repo, but won't be accepting new contributions, since we are going to be removing it from the repo after.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants