private void OnScrollEvent(object sender, TableSourceEvents e) { var source = Source; if (source != null && this._isDisposing == false) { source.FireScrollEvent(new ScrollEventArgs { iOSFirstCellVisible = e.FirstViewCell, iOSLastCellVisible = e.LastViewCell, iOSFirstPositionVisible = e.FirstRow, iOSLastPositionVisible = e.LastRow, iOSFirstRowVisible = e.IsFirstRowVisible, iOSLastRowVisible = e.IsLastRowVisible, YPosition = e.Y }); } }
public override void WillDisplay(UITableView tableView, UITableViewCell cell, Foundation.NSIndexPath indexPath) { var visibleCell = tableView.VisibleCells; if (visibleCell.Count() > 0) { var first = visibleCell.First(); var last = visibleCell.Last(); var firstCellPath = tableView.IndexPathForCell(first); var lastCellPath = tableView.IndexPathForCell(last); ViewCell firstViewCell = null; ViewCell lastViewCell = null; try { firstViewCell = first.GetType().GetProperty("ViewCell").GetValue(first) as Xamarin.Forms.ViewCell; lastViewCell = last.GetType().GetProperty("ViewCell").GetValue(last) as Xamarin.Forms.ViewCell; } catch { } var sectionsAmount = tableView.NumberOfSections(); var rowsAmount = tableView.NumberOfRowsInSection(indexPath.Section); if (indexPath.Section == sectionsAmount - 1 && indexPath.Row == rowsAmount - 1) { // This is the last cell in the table this._IsFirstRowVisible = false; this._IsLastRowVisible = true; } else if (indexPath.Section == 0 && (indexPath.Row == 0)) { this._IsFirstRowVisible = false; this._IsLastRowVisible = true; } else if (this._IsStartedScrolling) { this._IsFirstRowVisible = false; this._IsLastRowVisible = false; } var handler = this.OnScrollEvent; // fire event if (handler != null) { var evt = new TableSourceEvents { Y = _LastYPosition, IsFirstRowVisible = this._IsFirstRowVisible, IsLastRowVisible = this._IsLastRowVisible, FirstViewCell = firstViewCell, LastViewCell = lastViewCell }; if (firstCellPath != null) { evt.FirstRow = new int[] { firstCellPath.Section, firstCellPath.Row }; } else { evt.FirstRow = new int[] { -1, -1 }; } if (lastCellPath != null) { evt.LastRow = new int[] { lastCellPath.Section, lastCellPath.Row }; } else { evt.LastRow = new int[] { -1, -1 }; } handler(this, evt); } } }