From 2eba7c66e4ba82d4077f53b3f4257db64db481d2 Mon Sep 17 00:00:00 2001 From: Vladimir Amiorkov Date: Fri, 20 Oct 2017 08:38:07 +0300 Subject: [PATCH] Fix for iOS 11 ListView top offset (#4919) * Changed the default value of the new iOS11 'contentInsetAdjustmentBehavior' property #4916 * Fixed missing ts definitions and added TODOs --- tns-core-modules/ui/list-view/list-view.ios.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tns-core-modules/ui/list-view/list-view.ios.ts b/tns-core-modules/ui/list-view/list-view.ios.ts index acf2e5e0e..2e3a5cc25 100644 --- a/tns-core-modules/ui/list-view/list-view.ios.ts +++ b/tns-core-modules/ui/list-view/list-view.ios.ts @@ -8,6 +8,7 @@ import { StackLayout } from "../layouts/stack-layout"; import { ProxyViewContainer } from "../proxy-view-container"; import { ios } from "../../utils/utils"; import { profile } from "../../profiling"; +import { device } from "../../platform"; export * from "./list-view-common"; @@ -204,6 +205,17 @@ class UITableViewRowHeightDelegateImpl extends NSObject implements UITableViewDe } } +// TODO: Remove this declaration when 'tns-platform-declarations' is update with iOS 11 declarations +declare const enum UIScrollViewContentInsetAdjustmentBehavior { + Automatic = 0, + + ScrollableAxes = 1, + + Never = 2, + + Always = 3 +} + export class ListView extends ListViewBase { public _ios: UITableView; private _dataSource; @@ -222,6 +234,11 @@ export class ListView extends ListViewBase { this._ios.estimatedRowHeight = DEFAULT_HEIGHT; this._ios.rowHeight = UITableViewAutomaticDimension; this._ios.dataSource = this._dataSource = DataSource.initWithOwner(new WeakRef(this)); + if (parseInt(device.sdkVersion) >= 11) { + // TODO: Remove the cast to 'any' when 'tns-platform-declarations' is update with iOS 11 declarations + (this._ios).contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentBehavior.Never; + } + this._delegate = UITableViewDelegateImpl.initWithOwner(new WeakRef(this)); this._heights = new Array(); this._map = new Map();