mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-18 22:01:42 +08:00
fix: iOS crash on iOS 14 when onLayout is called without a nativeView
This commit is contained in:
@ -165,7 +165,7 @@ export class ScrollView extends ScrollViewBase {
|
|||||||
|
|
||||||
const nativeView = this.nativeViewProtected;
|
const nativeView = this.nativeViewProtected;
|
||||||
|
|
||||||
if (majorVersion > 10) {
|
if (nativeView && majorVersion > 10) {
|
||||||
// Disable automatic adjustment of scroll view insets
|
// Disable automatic adjustment of scroll view insets
|
||||||
// Consider exposing this as property with all 4 modes
|
// Consider exposing this as property with all 4 modes
|
||||||
// https://developer.apple.com/documentation/uikit/uiscrollview/contentinsetadjustmentbehavior
|
// https://developer.apple.com/documentation/uikit/uiscrollview/contentinsetadjustmentbehavior
|
||||||
@ -182,7 +182,10 @@ export class ScrollView extends ScrollViewBase {
|
|||||||
height = Math.max(this._contentMeasuredHeight, height);
|
height = Math.max(this._contentMeasuredHeight, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (nativeView) {
|
||||||
nativeView.contentSize = CGSizeMake(layout.toDeviceIndependentPixels(scrollWidth), layout.toDeviceIndependentPixels(scrollHeight));
|
nativeView.contentSize = CGSizeMake(layout.toDeviceIndependentPixels(scrollWidth), layout.toDeviceIndependentPixels(scrollHeight));
|
||||||
|
}
|
||||||
|
|
||||||
View.layoutChild(this, this.layoutView, insets.left, insets.top, insets.left + width, insets.top + height);
|
View.layoutChild(this, this.layoutView, insets.left, insets.top, insets.left + width, insets.top + height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user