Skip to content

Commit

Permalink
fix(iOS): fix component layout issue (#915)
Browse files Browse the repository at this point in the history
  • Loading branch information
krozniata authored Nov 19, 2024
1 parent e6f63c2 commit 06c8e8f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
3 changes: 2 additions & 1 deletion example/src/HeadphonesCarouselExample.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -261,9 +261,10 @@ export default function HeadphonesCarouselExample() {
}
)}
>
{data.map((item, index) => (
{data.map(({ key, ...item }, index) => (
<View collapsable={false} key={index}>
<Item
key={key}
{...item}
scrollOffsetAnimatedValue={scrollOffsetAnimatedValue}
positionAnimatedValue={positionAnimatedValue}
Expand Down
13 changes: 4 additions & 9 deletions ios/LEGACY/Fabric/LEGACY_RNCPagerViewComponentView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,13 @@ - (void)willMoveToSuperview:(UIView *)newSuperview {
#pragma mark - React API

- (void)mountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index {
UIViewController *wrapper = [[UIViewController alloc] initWithView:childComponentView];
[_nativeChildrenViewControllers insertObject:wrapper atIndex:index];
[self goTo:_currentIndex animated:NO];
UIViewController *vc = [UIViewController new];
[vc.view addSubview:childComponentView];
[_nativeChildrenViewControllers insertObject:vc atIndex:index];
}

- (void)unmountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index {
[[_nativeChildrenViewControllers objectAtIndex:index].view removeFromSuperview];
[_nativeChildrenViewControllers objectAtIndex:index].view = nil;
[childComponentView removeFromSuperview];
[_nativeChildrenViewControllers removeObjectAtIndex:index];

NSInteger maxPage = _nativeChildrenViewControllers.count - 1;
Expand All @@ -119,11 +118,7 @@ -(void)updateLayoutMetrics:(const facebook::react::LayoutMetrics &)layoutMetrics

-(void)prepareForRecycle {
[super prepareForRecycle];

_nativeChildrenViewControllers = [[NSMutableArray alloc] init];
[_nativePageViewController.view removeFromSuperview];
_nativePageViewController = nil;

_currentIndex = -1;
}

Expand Down

0 comments on commit 06c8e8f

Please sign in to comment.