[ReactNative] prevent ScrollView content offset from changing during layout

Summary:
-[UIScrollView setFrame:] changes the content offset, which we want to do manually.  Preserve the old offset during layout.
This commit is contained in:
Zack Gomez 2015-07-28 14:23:59 -07:00
parent b812b0ee2e
commit 068f396c9b
1 changed files with 3 additions and 0 deletions

View File

@ -461,7 +461,10 @@ RCT_NOT_IMPLEMENTED(-initWithCoder:(NSCoder *)aDecoder)
[super layoutSubviews]; [super layoutSubviews];
RCTAssert(self.subviews.count == 1, @"we should only have exactly one subview"); RCTAssert(self.subviews.count == 1, @"we should only have exactly one subview");
RCTAssert([self.subviews lastObject] == _scrollView, @"our only subview should be a scrollview"); RCTAssert([self.subviews lastObject] == _scrollView, @"our only subview should be a scrollview");
CGPoint originalOffset = _scrollView.contentOffset;
_scrollView.frame = self.bounds; _scrollView.frame = self.bounds;
_scrollView.contentOffset = originalOffset;
[RCTView autoAdjustInsetsForView:self [RCTView autoAdjustInsetsForView:self
withScrollView:_scrollView withScrollView:_scrollView