Skip to content

Commit 2eba7c6

Browse files
VladimirAmiorkovHristo Hristov
authored andcommitted
Fix for iOS 11 ListView top offset (NativeScript#4919)
* Changed the default value of the new iOS11 'contentInsetAdjustmentBehavior' property NativeScript#4916 * Fixed missing ts definitions and added TODOs
1 parent 7c68953 commit 2eba7c6

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

tns-core-modules/ui/list-view/list-view.ios.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { StackLayout } from "../layouts/stack-layout";
88
import { ProxyViewContainer } from "../proxy-view-container";
99
import { ios } from "../../utils/utils";
1010
import { profile } from "../../profiling";
11+
import { device } from "../../platform";
1112

1213
export * from "./list-view-common";
1314

@@ -204,6 +205,17 @@ class UITableViewRowHeightDelegateImpl extends NSObject implements UITableViewDe
204205
}
205206
}
206207

208+
// TODO: Remove this declaration when 'tns-platform-declarations' is update with iOS 11 declarations
209+
declare const enum UIScrollViewContentInsetAdjustmentBehavior {
210+
Automatic = 0,
211+
212+
ScrollableAxes = 1,
213+
214+
Never = 2,
215+
216+
Always = 3
217+
}
218+
207219
export class ListView extends ListViewBase {
208220
public _ios: UITableView;
209221
private _dataSource;
@@ -222,6 +234,11 @@ export class ListView extends ListViewBase {
222234
this._ios.estimatedRowHeight = DEFAULT_HEIGHT;
223235
this._ios.rowHeight = UITableViewAutomaticDimension;
224236
this._ios.dataSource = this._dataSource = DataSource.initWithOwner(new WeakRef(this));
237+
if (parseInt(device.sdkVersion) >= 11) {
238+
// TODO: Remove the cast to 'any' when 'tns-platform-declarations' is update with iOS 11 declarations
239+
(<any>this._ios).contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentBehavior.Never;
240+
}
241+
225242
this._delegate = UITableViewDelegateImpl.initWithOwner(new WeakRef(this));
226243
this._heights = new Array<number>();
227244
this._map = new Map<ListViewCell, View>();

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy