@@ -19,6 +19,7 @@ @interface RNCPagerViewComponentView () <RCTRNCViewPagerViewProtocol, UIPageView
19
19
@end
20
20
21
21
@implementation RNCPagerViewComponentView {
22
+ LayoutMetrics _layoutMetrics;
22
23
UIScrollView *scrollView;
23
24
}
24
25
@@ -66,15 +67,10 @@ - (instancetype)initWithFrame:(CGRect)frame
66
67
return self;
67
68
}
68
69
69
- -(void )layoutSubviews {
70
- [super layoutSubviews ];
71
-
72
- [_nativePageViewController setViewControllers: @[[_nativeChildrenViewControllers objectAtIndex: _currentIndex]] direction: [self isLtrLayout ] ? UIPageViewControllerNavigationDirectionForward : UIPageViewControllerNavigationDirectionReverse animated: NO completion: nil ];
73
- }
74
-
75
70
- (void )willMoveToSuperview : (UIView *)newSuperview {
76
71
if (newSuperview != nil ) {
77
72
[self initializeNativePageViewController ];
73
+ [self goTo: _currentIndex animated: NO ];
78
74
}
79
75
}
80
76
@@ -90,7 +86,7 @@ - (void)unmountChildComponentView:(UIView<RCTComponentViewProtocol> *)childCompo
90
86
[[_nativeChildrenViewControllers objectAtIndex: index].view removeFromSuperview ];
91
87
[_nativeChildrenViewControllers objectAtIndex: index].view = nil ;
92
88
[_nativeChildrenViewControllers removeObjectAtIndex: index];
93
-
89
+
94
90
NSInteger maxPage = _nativeChildrenViewControllers.count - 1 ;
95
91
96
92
if (self.currentIndex >= maxPage) {
@@ -99,6 +95,13 @@ - (void)unmountChildComponentView:(UIView<RCTComponentViewProtocol> *)childCompo
99
95
}
100
96
101
97
98
+ -(void )updateLayoutMetrics : (const facebook::react::LayoutMetrics &)layoutMetrics oldLayoutMetrics : (const facebook::react::LayoutMetrics &)oldLayoutMetrics {
99
+ [super updateLayoutMetrics: layoutMetrics oldLayoutMetrics: _layoutMetrics];
100
+ self.contentView .frame = RCTCGRectFromRect (_layoutMetrics.getContentFrame ());
101
+ _layoutMetrics = layoutMetrics;
102
+ }
103
+
104
+
102
105
-(void )prepareForRecycle {
103
106
[super prepareForRecycle ];
104
107
0 commit comments