mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
Merge pull request #257 from NativeScript/ios-list-view-sanity-fixes
Fix some crashes for ListView's iOS UITableView
This commit is contained in:
@@ -99,23 +99,22 @@ class UITableViewDelegateImpl extends NSObject implements UITableViewDelegate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public tableViewHeightForRowAtIndexPath(tableView: UITableView, indexPath: NSIndexPath): number {
|
public tableViewHeightForRowAtIndexPath(tableView: UITableView, indexPath: NSIndexPath): number {
|
||||||
if (utils.ios.MajorVersion < 8) {
|
var height = undefined;
|
||||||
// in iOS 7.1 this method is called before tableViewCellForRowAtIndexPath so we need fake cell to measure its content.
|
if (utils.ios.MajorVersion >= 8) {
|
||||||
|
height = this._owner.getHeight(indexPath.row);
|
||||||
|
}
|
||||||
|
if (utils.ios.MajorVersion < 8 || height === undefined) {
|
||||||
|
// 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.
|
||||||
var cell = this._measureCell;
|
var cell = this._measureCell;
|
||||||
if (!cell) {
|
if (!cell) {
|
||||||
this._measureCell = tableView.dequeueReusableCellWithIdentifier(CELLIDENTIFIER) || ListViewCell.new();
|
this._measureCell = tableView.dequeueReusableCellWithIdentifier(CELLIDENTIFIER) || ListViewCell.new();
|
||||||
cell = this._measureCell;
|
cell = this._measureCell;
|
||||||
}
|
}
|
||||||
|
|
||||||
return this._owner._prepareCell(cell, indexPath);
|
height = this._owner._prepareCell(cell, indexPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
return this._owner.getHeight(indexPath.row);
|
return height;
|
||||||
}
|
|
||||||
|
|
||||||
public tableViewEstimatedHeightForRowAtIndexPath(tableView: UITableView, indexPath: NSIndexPath): number {
|
|
||||||
// TODO: Consider exposing such property on ListView.
|
|
||||||
return DEFAULT_HEIGHT;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -148,6 +147,7 @@ export class ListView extends common.ListView {
|
|||||||
this._ios.registerClassForCellReuseIdentifier(ListViewCell.class(), CELLIDENTIFIER);
|
this._ios.registerClassForCellReuseIdentifier(ListViewCell.class(), CELLIDENTIFIER);
|
||||||
this._ios.autoresizesSubviews = false;
|
this._ios.autoresizesSubviews = false;
|
||||||
this._ios.autoresizingMask = UIViewAutoresizing.UIViewAutoresizingNone;
|
this._ios.autoresizingMask = UIViewAutoresizing.UIViewAutoresizingNone;
|
||||||
|
this._ios.estimatedRowHeight = DEFAULT_HEIGHT;
|
||||||
|
|
||||||
var dataSource = DataSource.new().initWithOwner(this);
|
var dataSource = DataSource.new().initWithOwner(this);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user