Skip to content

Commit 068dd8b

Browse files
committed
Fixed crash due to asserts in scrollToRowAtIndexPathAtScrollPositionAnimated for ListView's UITableView instance. Fixed a case where the UITableView fails to calculate its layout when the page it is displayed in is navigated to, from and back to.
1 parent 137688d commit 068dd8b

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

ui/list-view/list-view.ios.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -99,23 +99,22 @@ class UITableViewDelegateImpl extends NSObject implements UITableViewDelegate {
9999
}
100100

101101
public tableViewHeightForRowAtIndexPath(tableView: UITableView, indexPath: NSIndexPath): number {
102-
if (utils.ios.MajorVersion < 8) {
103-
// in iOS 7.1 this method is called before tableViewCellForRowAtIndexPath so we need fake cell to measure its content.
102+
var height = undefined;
103+
if (utils.ios.MajorVersion >= 8) {
104+
height = this._owner.getHeight(indexPath.row);
105+
}
106+
if (utils.ios.MajorVersion < 8 || height === undefined) {
107+
// in iOS 7.1 (or iOS8+ after call to scrollToRowAtIndexPath:atScrollPosition:animated:) this method is called before tableViewCellForRowAtIndexPath so we need fake cell to measure its content.
104108
var cell = this._measureCell;
105109
if (!cell) {
106110
this._measureCell = tableView.dequeueReusableCellWithIdentifier(CELLIDENTIFIER) || ListViewCell.new();
107111
cell = this._measureCell;
108112
}
109113

110-
return this._owner._prepareCell(cell, indexPath);
114+
height = this._owner._prepareCell(cell, indexPath);
111115
}
112116

113-
return this._owner.getHeight(indexPath.row);
114-
}
115-
116-
public tableViewEstimatedHeightForRowAtIndexPath(tableView: UITableView, indexPath: NSIndexPath): number {
117-
// TODO: Consider exposing such property on ListView.
118-
return DEFAULT_HEIGHT;
117+
return height;
119118
}
120119
}
121120

@@ -148,6 +147,7 @@ export class ListView extends common.ListView {
148147
this._ios.registerClassForCellReuseIdentifier(ListViewCell.class(), CELLIDENTIFIER);
149148
this._ios.autoresizesSubviews = false;
150149
this._ios.autoresizingMask = UIViewAutoresizing.UIViewAutoresizingNone;
150+
this._ios.estimatedRowHeight = DEFAULT_HEIGHT;
151151

152152
var dataSource = DataSource.new().initWithOwner(this);
153153

0 commit comments

Comments
 (0)